i2c: nomadik: Add Device Tree support to the Nomadik I2C driver
Here we apply the bindings required for successful Device Tree probing of the i2c-nomadik driver. Signed-off-by: Lee Jones <lee.jones@linaro.org> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
This commit is contained in:
23
Documentation/devicetree/bindings/i2c/nomadik.txt
Normal file
23
Documentation/devicetree/bindings/i2c/nomadik.txt
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
I2C for Nomadik based systems
|
||||||
|
|
||||||
|
Required (non-standard) properties:
|
||||||
|
- Nil
|
||||||
|
|
||||||
|
Recommended (non-standard) properties:
|
||||||
|
- clock-frequency : Maximum bus clock frequency for the device
|
||||||
|
|
||||||
|
Optional (non-standard) properties:
|
||||||
|
- Nil
|
||||||
|
|
||||||
|
Example :
|
||||||
|
|
||||||
|
i2c@80004000 {
|
||||||
|
compatible = "stericsson,db8500-i2c", "st,nomadik-i2c";
|
||||||
|
reg = <0x80004000 0x1000>;
|
||||||
|
interrupts = <0 21 0x4>;
|
||||||
|
#address-cells = <1>;
|
||||||
|
#size-cells = <0>;
|
||||||
|
v-i2c-supply = <&db8500_vape_reg>;
|
||||||
|
|
||||||
|
clock-frequency = <400000>;
|
||||||
|
};
|
@@ -24,6 +24,8 @@
|
|||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/pm_runtime.h>
|
#include <linux/pm_runtime.h>
|
||||||
#include <linux/platform_data/i2c-nomadik.h>
|
#include <linux/platform_data/i2c-nomadik.h>
|
||||||
|
#include <linux/of.h>
|
||||||
|
#include <linux/of_i2c.h>
|
||||||
|
|
||||||
#define DRIVER_NAME "nmk-i2c"
|
#define DRIVER_NAME "nmk-i2c"
|
||||||
|
|
||||||
@@ -913,18 +915,42 @@ static struct nmk_i2c_controller u8500_i2c = {
|
|||||||
.sm = I2C_FREQ_MODE_FAST,
|
.sm = I2C_FREQ_MODE_FAST,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void nmk_i2c_of_probe(struct device_node *np,
|
||||||
|
struct nmk_i2c_controller *pdata)
|
||||||
|
{
|
||||||
|
of_property_read_u32(np, "clock-frequency", &pdata->clk_freq);
|
||||||
|
|
||||||
|
/* This driver only supports 'standard' and 'fast' modes of operation. */
|
||||||
|
if (pdata->clk_freq <= 100000)
|
||||||
|
pdata->sm = I2C_FREQ_MODE_STANDARD;
|
||||||
|
else
|
||||||
|
pdata->sm = I2C_FREQ_MODE_FAST;
|
||||||
|
}
|
||||||
|
|
||||||
static atomic_t adapter_id = ATOMIC_INIT(0);
|
static atomic_t adapter_id = ATOMIC_INIT(0);
|
||||||
|
|
||||||
static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
|
static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct nmk_i2c_controller *pdata = adev->dev.platform_data;
|
struct nmk_i2c_controller *pdata = adev->dev.platform_data;
|
||||||
|
struct device_node *np = adev->dev.of_node;
|
||||||
struct nmk_i2c_dev *dev;
|
struct nmk_i2c_dev *dev;
|
||||||
struct i2c_adapter *adap;
|
struct i2c_adapter *adap;
|
||||||
|
|
||||||
if (!pdata)
|
if (!pdata) {
|
||||||
/* No i2c configuration found, using the default. */
|
if (np) {
|
||||||
pdata = &u8500_i2c;
|
pdata = devm_kzalloc(&adev->dev, sizeof(*pdata), GFP_KERNEL);
|
||||||
|
if (!pdata) {
|
||||||
|
ret = -ENOMEM;
|
||||||
|
goto err_no_mem;
|
||||||
|
}
|
||||||
|
/* Provide the default configuration as a base. */
|
||||||
|
memcpy(pdata, &u8500_i2c, sizeof(struct nmk_i2c_controller));
|
||||||
|
nmk_i2c_of_probe(np, pdata);
|
||||||
|
} else
|
||||||
|
/* No i2c configuration found, using the default. */
|
||||||
|
pdata = &u8500_i2c;
|
||||||
|
}
|
||||||
|
|
||||||
dev = kzalloc(sizeof(struct nmk_i2c_dev), GFP_KERNEL);
|
dev = kzalloc(sizeof(struct nmk_i2c_dev), GFP_KERNEL);
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
@@ -960,6 +986,7 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
adap = &dev->adap;
|
adap = &dev->adap;
|
||||||
|
adap->dev.of_node = np;
|
||||||
adap->dev.parent = &adev->dev;
|
adap->dev.parent = &adev->dev;
|
||||||
adap->owner = THIS_MODULE;
|
adap->owner = THIS_MODULE;
|
||||||
adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
|
adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
|
||||||
@@ -989,6 +1016,8 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
|
|||||||
goto err_add_adap;
|
goto err_add_adap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
of_i2c_register_devices(adap);
|
||||||
|
|
||||||
pm_runtime_put(&adev->dev);
|
pm_runtime_put(&adev->dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -28,7 +28,7 @@ enum i2c_freq_mode {
|
|||||||
* @sm: speed mode
|
* @sm: speed mode
|
||||||
*/
|
*/
|
||||||
struct nmk_i2c_controller {
|
struct nmk_i2c_controller {
|
||||||
unsigned long clk_freq;
|
u32 clk_freq;
|
||||||
unsigned short slsu;
|
unsigned short slsu;
|
||||||
unsigned char tft;
|
unsigned char tft;
|
||||||
unsigned char rft;
|
unsigned char rft;
|
||||||
|
Reference in New Issue
Block a user