public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] i2c: at91: Add missing probe function to device driver
@ 2017-07-31  1:56 Wenyou Yang
  2017-08-07  7:17 ` Heiko Schocher
  2017-08-10 10:08 ` Heiko Schocher
  0 siblings, 2 replies; 3+ messages in thread
From: Wenyou Yang @ 2017-07-31  1:56 UTC (permalink / raw)
  To: u-boot

Add missing probe function to the device driver to active a device.

Signed-off-by: Wenyou Yang <wenyou.yang@microchip.com>
---

 drivers/i2c/at91_i2c.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/at91_i2c.c b/drivers/i2c/at91_i2c.c
index b7298cf774..d394044f80 100644
--- a/drivers/i2c/at91_i2c.c
+++ b/drivers/i2c/at91_i2c.c
@@ -199,7 +199,7 @@ static int at91_i2c_enable_clk(struct udevice *dev)
 	return 0;
 }
 
-static int at91_i2c_probe(struct udevice *dev, uint chip, uint chip_flags)
+static int at91_i2c_probe_chip(struct udevice *dev, uint chip, uint chip_flags)
 {
 	struct at91_i2c_bus *bus = dev_get_priv(dev);
 	struct at91_i2c_regs *reg = bus->regs;
@@ -254,11 +254,32 @@ static int at91_i2c_ofdata_to_platdata(struct udevice *dev)
 
 static const struct dm_i2c_ops at91_i2c_ops = {
 	.xfer		= at91_i2c_xfer,
-	.probe_chip	= at91_i2c_probe,
+	.probe_chip	= at91_i2c_probe_chip,
 	.set_bus_speed	= at91_i2c_set_bus_speed,
 	.get_bus_speed	= at91_i2c_get_bus_speed,
 };
 
+static int at91_i2c_probe(struct udevice *dev)
+{
+	struct at91_i2c_bus *bus = dev_get_priv(dev);
+	struct at91_i2c_regs *reg = bus->regs;
+	int ret;
+
+	ret = at91_i2c_enable_clk(dev);
+	if (ret)
+		return ret;
+
+	writel(TWI_CR_SWRST, &reg->cr);
+
+	at91_calc_i2c_clock(dev, bus->clock_frequency);
+
+	writel(bus->cwgr_val, &reg->cwgr);
+	writel(TWI_CR_MSEN, &reg->cr);
+	writel(TWI_CR_SVDIS, &reg->cr);
+
+	return 0;
+}
+
 static const struct at91_i2c_pdata at91rm9200_config = {
 	.clk_max_div = 5,
 	.clk_offset = 3,
@@ -315,6 +336,7 @@ U_BOOT_DRIVER(i2c_at91) = {
 	.name	= "i2c_at91",
 	.id	= UCLASS_I2C,
 	.of_match = at91_i2c_ids,
+	.probe = at91_i2c_probe,
 	.ofdata_to_platdata = at91_i2c_ofdata_to_platdata,
 	.per_child_auto_alloc_size = sizeof(struct dm_i2c_chip),
 	.priv_auto_alloc_size = sizeof(struct at91_i2c_bus),
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] i2c: at91: Add missing probe function to device driver
  2017-07-31  1:56 [U-Boot] [PATCH] i2c: at91: Add missing probe function to device driver Wenyou Yang
@ 2017-08-07  7:17 ` Heiko Schocher
  2017-08-10 10:08 ` Heiko Schocher
  1 sibling, 0 replies; 3+ messages in thread
From: Heiko Schocher @ 2017-08-07  7:17 UTC (permalink / raw)
  To: u-boot

Hello Wenyou,

Am 31.07.2017 um 03:56 schrieb Wenyou Yang:
> Add missing probe function to the device driver to active a device.
>
> Signed-off-by: Wenyou Yang <wenyou.yang@microchip.com>
> ---
>
>   drivers/i2c/at91_i2c.c | 26 ++++++++++++++++++++++++--
>   1 file changed, 24 insertions(+), 2 deletions(-)

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>
> diff --git a/drivers/i2c/at91_i2c.c b/drivers/i2c/at91_i2c.c
> index b7298cf774..d394044f80 100644
> --- a/drivers/i2c/at91_i2c.c
> +++ b/drivers/i2c/at91_i2c.c
> @@ -199,7 +199,7 @@ static int at91_i2c_enable_clk(struct udevice *dev)
>   	return 0;
>   }
>
> -static int at91_i2c_probe(struct udevice *dev, uint chip, uint chip_flags)
> +static int at91_i2c_probe_chip(struct udevice *dev, uint chip, uint chip_flags)
>   {
>   	struct at91_i2c_bus *bus = dev_get_priv(dev);
>   	struct at91_i2c_regs *reg = bus->regs;
> @@ -254,11 +254,32 @@ static int at91_i2c_ofdata_to_platdata(struct udevice *dev)
>
>   static const struct dm_i2c_ops at91_i2c_ops = {
>   	.xfer		= at91_i2c_xfer,
> -	.probe_chip	= at91_i2c_probe,
> +	.probe_chip	= at91_i2c_probe_chip,
>   	.set_bus_speed	= at91_i2c_set_bus_speed,
>   	.get_bus_speed	= at91_i2c_get_bus_speed,
>   };
>
> +static int at91_i2c_probe(struct udevice *dev)
> +{
> +	struct at91_i2c_bus *bus = dev_get_priv(dev);
> +	struct at91_i2c_regs *reg = bus->regs;
> +	int ret;
> +
> +	ret = at91_i2c_enable_clk(dev);
> +	if (ret)
> +		return ret;
> +
> +	writel(TWI_CR_SWRST, &reg->cr);
> +
> +	at91_calc_i2c_clock(dev, bus->clock_frequency);
> +
> +	writel(bus->cwgr_val, &reg->cwgr);
> +	writel(TWI_CR_MSEN, &reg->cr);
> +	writel(TWI_CR_SVDIS, &reg->cr);
> +
> +	return 0;
> +}
> +
>   static const struct at91_i2c_pdata at91rm9200_config = {
>   	.clk_max_div = 5,
>   	.clk_offset = 3,
> @@ -315,6 +336,7 @@ U_BOOT_DRIVER(i2c_at91) = {
>   	.name	= "i2c_at91",
>   	.id	= UCLASS_I2C,
>   	.of_match = at91_i2c_ids,
> +	.probe = at91_i2c_probe,
>   	.ofdata_to_platdata = at91_i2c_ofdata_to_platdata,
>   	.per_child_auto_alloc_size = sizeof(struct dm_i2c_chip),
>   	.priv_auto_alloc_size = sizeof(struct at91_i2c_bus),
>

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] i2c: at91: Add missing probe function to device driver
  2017-07-31  1:56 [U-Boot] [PATCH] i2c: at91: Add missing probe function to device driver Wenyou Yang
  2017-08-07  7:17 ` Heiko Schocher
@ 2017-08-10 10:08 ` Heiko Schocher
  1 sibling, 0 replies; 3+ messages in thread
From: Heiko Schocher @ 2017-08-10 10:08 UTC (permalink / raw)
  To: u-boot

Hello Wenyou,

Am 31.07.2017 um 03:56 schrieb Wenyou Yang:
> Add missing probe function to the device driver to active a device.
>
> Signed-off-by: Wenyou Yang <wenyou.yang@microchip.com>
> ---
>
>   drivers/i2c/at91_i2c.c | 26 ++++++++++++++++++++++++--
>   1 file changed, 24 insertions(+), 2 deletions(-)

applied to u-boot-i2c.git

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-08-10 10:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-31  1:56 [U-Boot] [PATCH] i2c: at91: Add missing probe function to device driver Wenyou Yang
2017-08-07  7:17 ` Heiko Schocher
2017-08-10 10:08 ` Heiko Schocher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox