lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <beffb088e82c40ae86cb05eebda33a66@svr-chch-ex1.atlnz.lc>
Date:   Tue, 13 Jun 2017 04:38:19 +0000
From:   Chris Packham <Chris.Packham@...iedtelesis.co.nz>
To:     "wsa@...-dreams.de" <wsa@...-dreams.de>,
        "linux-i2c@...r.kernel.org" <linux-i2c@...r.kernel.org>
CC:     "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Rob Herring <robh+dt@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        "devicetree@...r.kernel.org" <devicetree@...r.kernel.org>
Subject: Re: [PATCH 1/4] i2c: pca-platform: add devicetree awareness

On 13/06/17 13:56, Chris Packham wrote:
> Allow devices that use this driver to be registered via a
> devicetree.
> 
> Signed-off-by: Chris Packham <chris.packham@...iedtelesis.co.nz>
> ---
>   .../devicetree/bindings/i2c/i2c-pca-platform.txt    | 18 ++++++++++++++++++
>   drivers/i2c/busses/i2c-pca-platform.c               | 21 +++++++++++++++++++++
>   2 files changed, 39 insertions(+)
>   create mode 100644 Documentation/devicetree/bindings/i2c/i2c-pca-platform.txt
> 
> diff --git a/Documentation/devicetree/bindings/i2c/i2c-pca-platform.txt b/Documentation/devicetree/bindings/i2c/i2c-pca-platform.txt
> new file mode 100644
> index 000000000000..47410bda3f37
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/i2c/i2c-pca-platform.txt
> @@ -0,0 +1,18 @@
> +* NXP PCA PCA9564/PCA9665 I2C controller
> +
> +The PCA9564/PCA9665 serves as an interface between most standard
> +parallel-bus microcontrollers/microprocessors and the serial I2C-bus
> +and allows the parallel bus system to communicate bi-directionally
> +with the I2C-bus.
> +
> +Required properties :
> +
> + - reg : Offset and length of the register set for the device
> + - compatible : one of "nxp,pca9564" or "nxp,pca9665"
> +
> +Optional properties
> + - interrupts : the interrupt number
> + - interrupt-parent : the phandle for the interrupt controller.
> +   If an interrupt is not specified polling will be used.
> + - gpios : gpio phandle to control device reset.
> + - clock-frequency : I2C bus frequency.
> \ No newline at end of file
> diff --git a/drivers/i2c/busses/i2c-pca-platform.c b/drivers/i2c/busses/i2c-pca-platform.c
> index 3bd2e7d06e4b..ca63fee400cb 100644
> --- a/drivers/i2c/busses/i2c-pca-platform.c
> +++ b/drivers/i2c/busses/i2c-pca-platform.c
> @@ -23,6 +23,9 @@
>   #include <linux/i2c-pca-platform.h>
>   #include <linux/gpio.h>
>   #include <linux/io.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/of_gpio.h>
>   
>   #include <asm/irq.h>
>   
> @@ -136,12 +139,15 @@ static int i2c_pca_pf_probe(struct platform_device *pdev)
>   	struct resource *res;
>   	struct i2c_pca9564_pf_platform_data *platform_data =
>   				dev_get_platdata(&pdev->dev);
> +	struct device_node *np = pdev->dev.of_node;
>   	int ret = 0;
>   	int irq;
>   
>   	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>   	irq = platform_get_irq(pdev, 0);
>   	/* If irq is 0, we do polling. */
> +	if (irq < 0)
> +		irq = 0;
>   
>   	if (res == NULL) {
>   		ret = -ENODEV;
> @@ -182,6 +188,11 @@ static int i2c_pca_pf_probe(struct platform_device *pdev)


I should be setting i2c->adap.dev.of_node somewhere around here so that 
the child nodes get automatically probed.

>   		i2c->adap.timeout = platform_data->timeout;
>   		i2c->algo_data.i2c_clock = platform_data->i2c_clock_speed;
>   		i2c->gpio = platform_data->gpio;
> +	} else if (np) {
> +		i2c->adap.timeout = HZ;
> +		i2c->gpio = of_get_gpio(np, 0);
> +		of_property_read_u32_index(np, "clock-frequency", 0,
> +					   &i2c->algo_data.i2c_clock);
>   	} else {
>   		i2c->adap.timeout = HZ;
>   		i2c->algo_data.i2c_clock = 59000;
> @@ -275,11 +286,21 @@ static int i2c_pca_pf_remove(struct platform_device *pdev)
>   	return 0;
>   }
>   
> +#ifdef CONFIG_OF
> +static const struct of_device_id i2c_pca_of_match_table[] = {
> +	{ .compatible = "nxp,pca9564" },
> +	{ .compatible = "nxp,pca9665" },
> +	{},
> +};
> +MODULE_DEVICE_TABLE(of, i2c_pca_of_match_table);
> +#endif
> +
>   static struct platform_driver i2c_pca_pf_driver = {
>   	.probe = i2c_pca_pf_probe,
>   	.remove = i2c_pca_pf_remove,
>   	.driver = {
>   		.name = "i2c-pca-platform",
> +		.of_match_table = of_match_ptr(i2c_pca_of_match_table),
>   	},
>   };
>   
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ