Message ID | 1484901827-16369-1-git-send-email-baoyou.xie@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | [v1,1/3] dt: bindings: add documentation for zx2967 family i2c controller | expand |
On Fri, Jan 20, 2017 at 04:43:47PM +0800, Baoyou Xie wrote: > +static int zx2967_i2c_probe(struct platform_device *pdev) > +{ > + struct resource *res; > + struct zx2967_i2c_info *zx_i2c = NULL; > + struct clk *clk; > + void __iomem *reg_base; > + int ret = 0; > + > + zx_i2c = devm_kzalloc(&pdev->dev, sizeof(*zx_i2c), GFP_KERNEL); > + if (!zx_i2c) > + return -ENOMEM; > + > + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > + if (!res) { > + dev_err(&pdev->dev, "missing io resource\n"); > + return -EINVAL; > + } > + > + reg_base = devm_ioremap_resource(&pdev->dev, res); > + if (IS_ERR(reg_base)) > + return PTR_ERR(reg_base); > + > + clk = devm_clk_get(&pdev->dev, NULL); > + if (IS_ERR(clk)) { > + dev_err(&pdev->dev, "missing controller clock"); > + return PTR_ERR(clk); > + } > + > + ret = clk_prepare_enable(clk); > + if (ret) { > + dev_err(&pdev->dev, "failed to enable i2c_clk\n"); > + return ret; > + } > + > + of_property_read_u32(pdev->dev.of_node, > + "clock-frequency", &zx_i2c->clk_freq); > + zx_i2c->reg_base = reg_base; > + zx_i2c->clk = clk; > + zx_i2c->irq = platform_get_irq(pdev, 0); > + zx_i2c->id = pdev->id; > + zx_i2c->dev = &pdev->dev; > + > + zx_i2c->pin_scl = devm_pinctrl_get_select(&pdev->dev, "scl"); > + if (IS_ERR(zx_i2c->pin_scl)) > + dev_info(&pdev->dev, "scl pin is not specified in dts\n"); > + > + zx_i2c->pin_sda = devm_pinctrl_get_select(&pdev->dev, "sda"); > + if (IS_ERR(zx_i2c->pin_sda)) > + dev_info(&pdev->dev, "sda pin is not specified in dts\n"); I don't understand why this is necessary. For most cases, we only need to specify needed pins in property 'pinctrl-0' and 'default' in 'pinctrl-names', and pinctrl/driver core will just set up the pins for the device. Shawn -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/Documentation/devicetree/bindings/i2c/i2c-zx2967.txt b/Documentation/devicetree/bindings/i2c/i2c-zx2967.txt new file mode 100644 index 0000000..cb806d1 --- /dev/null +++ b/Documentation/devicetree/bindings/i2c/i2c-zx2967.txt @@ -0,0 +1,22 @@ +ZTE zx2967 I2C controller + +Required properties: + - compatible: must be "zte,zx296718-i2c" + - reg: physical address and length of the device registers + - interrupts: a single interrupt specifier + - clocks: clock for the device + - #address-cells: should be <1> + - #size-cells: should be <0> + - clock-frequency: the desired I2C bus clock frequency. + +Examples: + + i2c@112000 { + compatible = "zte,zx296718-i2c"; + reg = <0x00112000 0x1000>; + interrupts = <GIC_SPI 112 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&osc24m>; + #address-cells = <1> + #size-cells = <0>; + clock-frequency = <1600000>; + };
This patch adds dt-binding documentation for zx2967 family i2c controller. Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org> --- .../devicetree/bindings/i2c/i2c-zx2967.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Documentation/devicetree/bindings/i2c/i2c-zx2967.txt -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html