From: Mugunthan V N <mugunthanvnm@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 04/16] dm: core: Add a new api to get indexed device address
Date: Tue, 17 Nov 2015 13:25:57 +0530 [thread overview]
Message-ID: <564ADD8D.3000700@ti.com> (raw)
In-Reply-To: <CAPnjgZ1pa3QacjKenqeduhgCYPXRdLgwUMDb7zfp7K2cGmCi6A@mail.gmail.com>
On Friday 06 November 2015 05:37 PM, Simon Glass wrote:
> +Stephen
>
> Hi,
>
> On 4 November 2015 at 01:16, Mugunthan V N <mugunthanvnm@ti.com> wrote:
>> Add new api to get device address based on index.
>>
>> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
>> ---
>> drivers/core/device.c | 16 ++++++++++++----
>> include/dm/device.h | 10 ++++++++++
>> 2 files changed, 22 insertions(+), 4 deletions(-)
>
> You are touching critical core code so I think we need to be careful here.
>
Okay
>>
>> diff --git a/drivers/core/device.c b/drivers/core/device.c
>> index 758f390..3cdcab5 100644
>> --- a/drivers/core/device.c
>> +++ b/drivers/core/device.c
>> @@ -581,18 +581,21 @@ const char *dev_get_uclass_name(struct udevice *dev)
>> return dev->uclass->uc_drv->name;
>> }
>>
>> -fdt_addr_t dev_get_addr(struct udevice *dev)
>> +fdt_addr_t dev_get_addr_index(struct udevice *dev, int index)
>> {
>> #if CONFIG_IS_ENABLED(OF_CONTROL)
>> fdt_addr_t addr;
>>
>> if (CONFIG_IS_ENABLED(OF_TRANSLATE)) {
>> const fdt32_t *reg;
>> + int len = 0;
>>
>> - reg = fdt_getprop(gd->fdt_blob, dev->of_offset, "reg", NULL);
>> - if (!reg)
>> + reg = fdt_getprop(gd->fdt_blob, dev->of_offset, "reg", &len);
>> + if (!reg || (len <= (index * sizeof(fdt32_t) * 2)))
>> return FDT_ADDR_T_NONE;
>>
>> + reg += index * 2;
>> +
>
> This seems to be assuming that the address and size each occupy a
> single cell, but that is not the case in general (e.g. with 64-bit
> machines).
>
> I think you need to call fdt_addr_cells() and fdt_size_cells(). See
> fdtdec_get_addr_size_auto_parent() as an example.
>
Okay, will use these in next version.
>> /*
>> * Use the full-fledged translate function for complex
>> * bus setups.
>> @@ -608,7 +611,7 @@ fdt_addr_t dev_get_addr(struct udevice *dev)
>> addr = fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
>> dev->parent->of_offset,
>> dev->of_offset, "reg",
>> - 0, NULL);
>> + index, NULL);
>> if (CONFIG_IS_ENABLED(SIMPLE_BUS) && addr != FDT_ADDR_T_NONE) {
>> if (device_get_uclass_id(dev->parent) == UCLASS_SIMPLE_BUS)
>> addr = simple_bus_translate(dev->parent, addr);
>> @@ -620,6 +623,11 @@ fdt_addr_t dev_get_addr(struct udevice *dev)
>> #endif
>> }
>>
>> +fdt_addr_t dev_get_addr(struct udevice *dev)
>> +{
>> + return dev_get_addr_index(dev, 0);
>> +}
>> +
>> bool device_has_children(struct udevice *dev)
>> {
>> return !list_empty(&dev->child_head);
>> diff --git a/include/dm/device.h b/include/dm/device.h
>> index 28ba4ca..4de66d7 100644
>> --- a/include/dm/device.h
>> +++ b/include/dm/device.h
>> @@ -454,6 +454,16 @@ int device_find_next_child(struct udevice **devp);
>> fdt_addr_t dev_get_addr(struct udevice *dev);
>>
>> /**
>> + * dev_get_addr() - Get the reg property of a device
>
> dev_get_addr_index
>
>> + *
>> + * @dev: Pointer to a device
>> + * @index: reg address array index
>
> I don't think this is sufficiently clear. Can you add a comment saying
> that the 'reg' property can hold a list of <addr, size> pairs and
> @index is used to select which one is used?
>
Will add more doc in next version
Regards
Mugunthan V N
next prev parent reply other threads:[~2015-11-17 7:55 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-04 8:16 [U-Boot] [PATCH v2 00/16] device model bring-up of ti-qspi on dra72, dra74 and am437x-sk evm Mugunthan V N
2015-11-04 8:16 ` [U-Boot] [PATCH v2 01/16] drivers: spi: ti_qspi: do not hard code chip select for memory map configuration Mugunthan V N
2015-11-06 12:07 ` Simon Glass
2015-11-08 13:31 ` Tom Rini
2015-11-17 6:13 ` Jagan Teki
2015-11-04 8:16 ` [U-Boot] [PATCH v2 02/16] drivers: spi:ti_qspi: change ti_qspi_slave to ti_qspi_priv for driver model conversion Mugunthan V N
2015-11-06 12:07 ` Simon Glass
2015-11-08 13:31 ` Tom Rini
2015-11-17 6:14 ` Jagan Teki
2015-11-04 8:16 ` [U-Boot] [PATCH v2 03/16] drivers: spi: ti_qspi: prepare driver for DM conversion Mugunthan V N
2015-11-06 12:07 ` Simon Glass
2015-11-17 7:50 ` Mugunthan V N
2015-11-17 6:21 ` Jagan Teki
2015-11-17 7:53 ` Mugunthan V N
2015-11-18 15:54 ` Mugunthan V N
2015-11-04 8:16 ` [U-Boot] [PATCH v2 04/16] dm: core: Add a new api to get indexed device address Mugunthan V N
2015-11-06 12:07 ` Simon Glass
2015-11-17 7:55 ` Mugunthan V N [this message]
2015-11-04 8:16 ` [U-Boot] [PATCH v2 05/16] spi: Add support for dual and quad mode Mugunthan V N
2015-11-08 13:31 ` Tom Rini
2015-11-17 6:29 ` Jagan Teki
2015-11-04 8:16 ` [U-Boot] [PATCH v2 06/16] dra7xx_evm: qspi: do not define DM_SPI and DM_SPI_FLASH for spl Mugunthan V N
2015-11-06 12:07 ` Simon Glass
2015-11-12 9:15 ` Mugunthan V N
2015-11-04 8:16 ` [U-Boot] [PATCH v2 07/16] dts: dra7: add spi alias for qspi Mugunthan V N
2015-11-08 13:31 ` Tom Rini
2015-11-04 8:16 ` [U-Boot] [PATCH v2 08/16] drivers: spi: ti_qspi: convert driver to adopt device driver model Mugunthan V N
2015-11-06 12:07 ` Simon Glass
2015-11-08 13:31 ` Tom Rini
2015-11-04 8:16 ` [U-Boot] [PATCH v2 09/16] arm: dts: dra7: add qspi register maps for memory map and control module Mugunthan V N
2015-11-08 13:31 ` Tom Rini
2015-11-12 9:03 ` Mugunthan V N
2015-11-12 12:47 ` Tom Rini
2015-11-14 7:31 ` Mugunthan V N
2015-11-16 2:13 ` Tom Rini
2015-11-17 7:59 ` Mugunthan V N
2015-11-04 8:16 ` [U-Boot] [PATCH v2 10/16] drivers: mtd: spi: sf_probe: add compatible for spansion spi flash Mugunthan V N
2015-11-06 12:07 ` Simon Glass
2015-11-12 9:12 ` Mugunthan V N
2015-11-12 12:48 ` Tom Rini
2015-11-16 21:08 ` Simon Glass
2015-11-17 8:05 ` Mugunthan V N
2015-11-04 8:16 ` [U-Boot] [PATCH v2 11/16] drivers: mtd: spi: sf_probe: add compatible for Macronix " Mugunthan V N
2015-11-06 12:07 ` Simon Glass
2015-11-04 8:16 ` [U-Boot] [PATCH v2 12/16] defconfig: dra72_evm: enable spi driver model Mugunthan V N
2015-11-08 13:32 ` Tom Rini
2015-11-04 8:16 ` [U-Boot] [PATCH v2 13/16] defconfig: dra74_evm: " Mugunthan V N
2015-11-08 13:32 ` Tom Rini
2015-11-04 8:16 ` [U-Boot] [PATCH v2 14/16] am43xx_evm: qspi: do not define DM_SPI and DM_SPI_FLASH for spl Mugunthan V N
2015-11-06 12:07 ` Simon Glass
2015-11-12 9:15 ` Mugunthan V N
2015-11-04 8:16 ` [U-Boot] [PATCH v2 15/16] arm: dts: am4372: add qspi register maps for memory map Mugunthan V N
2015-11-08 13:32 ` Tom Rini
2015-11-12 9:17 ` Mugunthan V N
2015-11-04 8:16 ` [U-Boot] [PATCH v2 16/16] defconfig: am437x_sk_evm: enable spi driver model Mugunthan V N
2015-11-08 13:32 ` Tom Rini
2015-11-17 9:18 ` Jagan Teki
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=564ADD8D.3000700@ti.com \
--to=mugunthanvnm@ti.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox