All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v9 18/49] rockchip: i2c: Update the driver to use the new clock ID
Date: Fri, 22 Jan 2016 06:24:14 +0100	[thread overview]
Message-ID: <56A1BCFE.70106@denx.de> (raw)
In-Reply-To: <1453430653-3280-19-git-send-email-sjg@chromium.org>

Hello Simon,

Am 22.01.2016 um 03:43 schrieb Simon Glass:
> We can use the new clk_get_by_index() function to get the correct clock.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v9: None
> Changes in v2:
> - Update call to clk_get_by_index()
>
>   drivers/i2c/rk_i2c.c | 38 ++++++++++++++++++++++----------------
>   1 file changed, 22 insertions(+), 16 deletions(-)

Thanks!

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

bye,
Heiko
> diff --git a/drivers/i2c/rk_i2c.c b/drivers/i2c/rk_i2c.c
> index ebdba35..3fceade 100644
> --- a/drivers/i2c/rk_i2c.c
> +++ b/drivers/i2c/rk_i2c.c
> @@ -30,10 +30,9 @@ DECLARE_GLOBAL_DATA_PTR;
>
>   struct rk_i2c {
>   	struct udevice *clk;
> -	struct udevice *pinctrl;
>   	struct i2c_regs *regs;
>   	unsigned int speed;
> -	enum periph_id id;
> +	int clk_id;
>   };
>
>   static inline void rk_i2c_get_div(int div, int *divh, int *divl)
> @@ -56,7 +55,7 @@ static void rk_i2c_set_clk(struct rk_i2c *i2c, uint32_t scl_rate)
>   	int div, divl, divh;
>
>   	/* First get i2c rate from pclk */
> -	i2c_rate = clk_get_periph_rate(i2c->clk, i2c->id);
> +	i2c_rate = clk_get_periph_rate(i2c->clk, i2c->clk_id);
>
>   	div = DIV_ROUND_UP(i2c_rate, scl_rate * 8) - 2;
>   	divh = 0;
> @@ -352,23 +351,29 @@ int rockchip_i2c_set_bus_speed(struct udevice *bus, unsigned int speed)
>   	return 0;
>   }
>
> -static int rockchip_i2c_probe(struct udevice *bus)
> +static int rockchip_i2c_ofdata_to_platdata(struct udevice *bus)
>   {
> -	struct rk_i2c *i2c = dev_get_priv(bus);
> +	struct rk_i2c *priv = dev_get_priv(bus);
>   	int ret;
>
> -	ret = uclass_get_device(UCLASS_PINCTRL, 0, &i2c->pinctrl);
> -	if (ret)
> -		return ret;
> -	ret = uclass_get_device(UCLASS_CLK, 0, &i2c->clk);
> -	if (ret)
> -		return ret;
> -	ret = pinctrl_get_periph_id(i2c->pinctrl, bus);
> -	if (ret < 0)
> +	ret = clk_get_by_index(bus, 0, &priv->clk);
> +	if (ret < 0) {
> +		debug("%s: Could not get clock for %s: %d\n", __func__,
> +		      bus->name, ret);
>   		return ret;
> -	i2c->id = ret;
> -	i2c->regs = (void *)dev_get_addr(bus);
> -	return pinctrl_request(i2c->pinctrl, i2c->id, 0);
> +	}
> +	priv->clk_id = ret;
> +
> +	return 0;
> +}
> +
> +static int rockchip_i2c_probe(struct udevice *bus)
> +{
> +	struct rk_i2c *priv = dev_get_priv(bus);
> +
> +	priv->regs = (void *)dev_get_addr(bus);
> +
> +	return 0;
>   }
>
>   static const struct dm_i2c_ops rockchip_i2c_ops = {
> @@ -385,6 +390,7 @@ U_BOOT_DRIVER(i2c_rockchip) = {
>   	.name	= "i2c_rockchip",
>   	.id	= UCLASS_I2C,
>   	.of_match = rockchip_i2c_ids,
> +	.ofdata_to_platdata = rockchip_i2c_ofdata_to_platdata,
>   	.probe	= rockchip_i2c_probe,
>   	.priv_auto_alloc_size = sizeof(struct rk_i2c),
>   	.ops	= &rockchip_i2c_ops,
>

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

  reply	other threads:[~2016-01-22  5:24 UTC|newest]

Thread overview: 101+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-22  2:43 [U-Boot] [PATCH v9 00/49] rockchip: Add support for cros_ec keyboard Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 01/49] dm: core: Don't set pinctrl for pinctrl devices Simon Glass
2016-01-22 15:17   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 02/49] dm: pinctrl: Add a function to parse PIN_CONFIG flags Simon Glass
2016-01-22 15:17   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 03/49] dm: pmic: Add 'reg status' to show all regulators Simon Glass
2016-01-22 15:17   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 04/49] dts: Bring in pinctrl device tree binding Simon Glass
2016-01-22 15:17   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 05/49] power: Add base support for the RK808 PMIC Simon Glass
2016-01-22 15:17   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 06/49] power: Add support for RK808 regulators Simon Glass
2016-01-22 15:17   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 07/49] dm: Add a power sequencing uclass Simon Glass
2016-01-22 15:17   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 08/49] rockchip: Avoid using MMC code when not booting from MMC Simon Glass
2016-01-22 15:17   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 09/49] rockchip: Convert the PMU IOMUX registers into an array Simon Glass
2016-01-22 15:17   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 10/49] rockchip: mmc: Use a pwrseq device if available Simon Glass
2016-01-22 15:17   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 11/49] rockchip: Correct the defconfig order Simon Glass
2016-01-22 15:17   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 12/49] rockchip: Use pwrseq for MMC start-up on jerry Simon Glass
2016-01-22 15:17   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 13/49] rockchip: jerry: Disable pmic-int-1 setup to avoid a hang Simon Glass
2016-01-22 15:17   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 14/49] rockchip: Use a separate clock ID for clocks Simon Glass
2016-01-22 15:17   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 15/49] rockchip: clock: Rename the general clock variable to gclk_rate Simon Glass
2016-01-22 15:17   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 16/49] rockchip: clk: Add a function to get a peripheral clock rate Simon Glass
2016-01-22 15:17   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 17/49] rockchip: clock: Add a function to find a clock by ID Simon Glass
2016-01-22 15:17   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 18/49] rockchip: i2c: Update the driver to use the new clock ID Simon Glass
2016-01-22  5:24   ` Heiko Schocher [this message]
2016-01-22 15:17   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 19/49] rockchip: spi: " Simon Glass
2016-01-22 15:17   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 20/49] rockchip: spi: Avoid setting the pinctrl twice Simon Glass
2016-01-22 15:18   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 21/49] rockchip: mmc: Update the driver to use the new clock ID Simon Glass
2016-01-22 15:18   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 22/49] rockchip: pinctrl: Add a full pinctrl driver Simon Glass
2016-01-22 15:18   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 23/49] rockchip: Move firefly and jerry to use the full pinctrl Simon Glass
2016-01-22 15:18   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 24/49] rockchip: jerry: Enable the RK808 PMIC and regulator Simon Glass
2016-01-22 15:18   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 25/49] rockchip: Disable simple-bus in SPL for firefly-rk3288, jerry Simon Glass
2016-01-22 15:18   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 26/49] rockchip: jerry: Drop unused options Simon Glass
2016-01-22 15:18   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 27/49] gpio: Allow 's' as an abbreviation for 'status' Simon Glass
2016-01-22 15:18   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 28/49] cros_ec: Disable the Chrome OS EC in SPL Simon Glass
2016-01-22 15:18   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 29/49] dm: i2c: Allow muxes to be enabled for SPL separately Simon Glass
2016-01-22  5:32   ` Heiko Schocher
2016-01-22 15:18     ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 30/49] spi: Correct device tree usage in spi_flash_decode_fdt() Simon Glass
2016-01-22 15:18   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 31/49] dm: power: Allow regulators to be omitted from SPL Simon Glass
2016-01-22 15:18   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 32/49] dm: pinctrl: Add a way for a GPIO driver to obtain a pin function Simon Glass
2016-01-22 15:18   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 33/49] dm: core: Export uclass_find_device_by_of_offset() Simon Glass
2016-01-22 15:18   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 34/49] dm: power: Tidy up debugging output and return values Simon Glass
2016-01-22 15:18   ` Simon Glass
2016-01-22  2:43 ` [U-Boot] [PATCH v9 35/49] dm: power: Allow regulators to not implement all operations Simon Glass
2016-01-22 15:18   ` Simon Glass
2016-01-22  2:44 ` [U-Boot] [PATCH v9 36/49] dm: clk: Add a simple version of clk_get_by_index() Simon Glass
2016-01-22 15:18   ` Simon Glass
2016-01-22  2:44 ` [U-Boot] [PATCH v9 37/49] rockchip: sdram: Use the rk_clr/setreg() interface Simon Glass
2016-01-22 15:18   ` Simon Glass
2016-01-22  2:44 ` [U-Boot] [PATCH v9 38/49] rockchip: reset: " Simon Glass
2016-01-22 15:18   ` Simon Glass
2016-01-22  2:44 ` [U-Boot] [PATCH v9 39/49] rockchip: spi: Remember the last speed to avoid re-setting it Simon Glass
2016-01-22 15:18   ` Simon Glass
2016-01-22  2:44 ` [U-Boot] [PATCH v9 40/49] rockchip: spi: Correct the bus init code Simon Glass
2016-01-22 15:19   ` Simon Glass
2016-01-22  2:44 ` [U-Boot] [PATCH v9 41/49] rockchip: clk: Make rkclk_get_clk() SoC-specific Simon Glass
2016-01-22 15:19   ` Simon Glass
2016-01-22  2:44 ` [U-Boot] [PATCH v9 42/49] rockchip: pinctrl: Reduce the size for SPL Simon Glass
2016-01-22 15:19   ` Simon Glass
2016-01-22  2:44 ` [U-Boot] [PATCH v9 43/49] rockchip: pinctrl: Implement the get_gpio_mux() method Simon Glass
2016-01-22 15:19   ` Simon Glass
2016-01-22  2:44 ` [U-Boot] [PATCH v9 44/49] rockchip: gpio: Read the GPIO value correctly Simon Glass
2016-01-22 15:19   ` Simon Glass
2016-01-22  2:44 ` [U-Boot] [PATCH v9 45/49] rockchip: gpio: Implement the get_function() method Simon Glass
2016-01-22 15:19   ` Simon Glass
2016-01-22  2:44 ` [U-Boot] [PATCH v9 46/49] rockchip: spi: Implement the delays Simon Glass
2016-01-22 15:19   ` Simon Glass
2016-01-22  2:44 ` [U-Boot] [PATCH v9 47/49] rockchip: spi: Correct chip-enable code Simon Glass
2016-01-22 15:19   ` Simon Glass
2016-01-22  2:44 ` [U-Boot] [PATCH v9 48/49] rockchip: spi: Remove the explicit pinctrl setting Simon Glass
2016-01-22 15:19   ` Simon Glass
2016-01-22  2:44 ` [U-Boot] [PATCH v9 49/49] rockchip: jerry: Enable the Chrome OS EC Simon Glass
2016-01-22 15:19   ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56A1BCFE.70106@denx.de \
    --to=hs@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.