* Re: [PATCHv2 9/9] arm: dts: am43x-gp-evm: Add matrix gpio keys.
From: Sourav Poddar @ 2014-02-21 14:28 UTC (permalink / raw)
To: Benoit Cousson
Cc: balbi, devicetree, tony, linux-omap, mark.rutland, lokeshvutla
In-Reply-To: <52D547F5.2080307@baylibre.com>
Hi Benoit,
On Tuesday 14 January 2014 07:51 PM, Benoit Cousson wrote:
> Hi Felipe,
>
> On 14/01/2014 14:14, Felipe Balbi wrote:
>> On Mon, Jan 13, 2014 at 10:13:13PM +0530, sourav wrote:
>>> Benoit,
>>>
>>> On Thursday 19 December 2013 06:03 PM, Sourav Poddar wrote:
>>>> Add gpio keys node for am43x gp evm.
>>>>
>>>> Signed-off-by: Sourav Poddar<sourav.poddar@ti.com>
>>>> ---
>>>> arch/arm/boot/dts/am437x-gp-evm.dts | 21 +++++++++++++++++++++
>>>> 1 file changed, 21 insertions(+)
>>>>
>>>> diff --git a/arch/arm/boot/dts/am437x-gp-evm.dts
>>>> b/arch/arm/boot/dts/am437x-gp-evm.dts
>>>> index 0dc248d..4eb72b8 100644
>>>> --- a/arch/arm/boot/dts/am437x-gp-evm.dts
>>>> +++ b/arch/arm/boot/dts/am437x-gp-evm.dts
>>>> @@ -13,6 +13,7 @@
>>>> #include "am4372.dtsi"
>>>> #include<dt-bindings/pinctrl/am43xx.h>
>>>> #include<dt-bindings/pwm/pwm.h>
>>>> +#include<dt-bindings/gpio/gpio.h>
>>>>
>>>> / {
>>>> model = "TI AM437x GP EVM";
>>>> @@ -24,6 +25,26 @@
>>>> brightness-levels =<0 51 53 56 62 75 101 152 255>;
>>>> default-brightness-level =<8>;
>>>> };
>>>> +
>>>> + matrix_keypad: matrix_keypad@0 {
>>>> + compatible = "gpio-matrix-keypad";
>>>> + debounce-delay-ms =<5>;
>>>> + col-scan-delay-us =<2>;
>>>> +
>>>> + row-gpios =<&gpio3 21 GPIO_ACTIVE_HIGH /* Bank3, pin21 */
>>>> + &gpio4 3 GPIO_ACTIVE_HIGH /* Bank4, pin3 */
>>>> + &gpio4 2 GPIO_ACTIVE_HIGH>; /* Bank4, pin2 */
>>>> +
>>>> + col-gpios =<&gpio3 19 GPIO_ACTIVE_HIGH /* Bank3, pin19 */
>>>> + &gpio3 20 GPIO_ACTIVE_HIGH>; /* Bank3, pin20 */
>>>> +
>>>> + linux,keymap =<0x00000201 /* P1 */
>>>> + 0x00010202 /* P2 */
>>>> + 0x01000067 /* UP */
>>>> + 0x0101006a /* RIGHT */
>>>> + 0x02000069 /* LEFT */
>>>> + 0x0201006c>; /* DOWN */
>>>> + };
>>>> };
>>>>
>>>> &am43xx_pinmux {
>>>
>>> ping on this series, this series is lying for a while.
>>> This series is based on your for_3.14 branch.
>>
>> Benoit, do you need us to do anything else to get this merged ? Sourav
>> already rebased the patches as you requested back in December 19th.
>
> Nope, I've just needed more BW. I'll apply it ASAP.
>
> Thanks,
> Benoit
>
Ping on this.
^ permalink raw reply
* Re: [PATCH 4/7] ECHI Platform: Merge ppc-of EHCI driver into the ehci-platform driver
From: Arnd Bergmann @ 2014-02-21 14:21 UTC (permalink / raw)
To: linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ
Cc: Mark Rutland, Alistair Popple,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org,
linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Tony Prisk
In-Reply-To: <20140221114803.GB8783-NuALmloUBlrZROr8t4l/smS4ubULX0JqMm0uRHvK7Nw@public.gmane.org>
On Friday 21 February 2014 11:48:03 Mark Rutland wrote:
> > +
> > + np = of_find_compatible_node(NULL, NULL, "ibm,usb-ohci-440epx");
> > + if (np != NULL) {
> > + /* claim we really affected by usb23 erratum */
> > + if (!of_address_to_resource(np, 0, &res))
> > + ehci->ohci_hcctrl_reg =
> > + devm_ioremap(&pdev->dev,
> > + res.start + OHCI_HCCTRL_OFFSET,
> > + OHCI_HCCTRL_LEN);
> > + else
> > + ehci_dbg(ehci, "%s: no ohci offset in fdt\n", __FILE__);
> > + if (!ehci->ohci_hcctrl_reg) {
> > + ehci_dbg(ehci, "%s: ioremap for ohci hcctrl failed\n",
> > + __FILE__);
> > + } else {
> > + ehci->has_amcc_usb23 = 1;
> > + }
> > + }
>
> As this is being dropped into a generic driver, it would be nice to have
> a comment explaining why we need to do this -- not everyone using this
> will know the powerpc history. It certainly seems odd to look for
> another node in the tree that this driver isn't necessarily handling,
> and that should probably be explained.
>
> As this bit of fixup is only needed for powerpc, it would be nice to not
> have to do it elsewhere. Perhaps these could be factored out into a
> ppc_platform_reset function that could be empty stub for other
> architectures.
How about using the .data field of the of_device_id array to point to
a structure of functions? That way you don't even have to call
of_device_is_compatible() here. Note that using of_find_compatible_node()
is the wrong approach anyway, you want to check the current device
for compatibility, not just any device I assume.
Arnd
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [RESEND][PATCH v4] gpio: davinci: reuse for keystone soc
From: Santosh Shilimkar @ 2014-02-21 14:18 UTC (permalink / raw)
To: Linus Walleij
Cc: Alexandre Courbot, davinci-linux-open-source, Grygorii Strashko,
devicetree, nsekhar, Rob Herring, linux-arm-kernel
In-Reply-To: <1392307125-27927-1-git-send-email-grygorii.strashko@ti.com>
Linus,
On Thursday 13 February 2014 10:58 AM, Grygorii Strashko wrote:
> The similar GPIO HW block is used by keystone SoCs as
> in Davinci SoCs.
> Hence, reuse Davinci GPIO driver for Keystone taking into
> account that Keystone contains ARM GIC IRQ controller which
> is implemented using IRQ Chip.
>
> Documentation:
> http://www.ti.com/lit/ug/sprugv1/sprugv1.pdf
>
> Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
> ---
> - rebased on top of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git
> branch: devel
> top commit: ef70bbe gpio: make gpiod_direction_output take a logical value
>
Can you please pick this one ? Its rebased as per your suggestion.
> .../devicetree/bindings/gpio/gpio-davinci.txt | 4 +-
> drivers/gpio/gpio-davinci.c | 48 ++++++++++++++++----
> 2 files changed, 42 insertions(+), 10 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/gpio/gpio-davinci.txt b/Documentation/devicetree/bindings/gpio/gpio-davinci.txt
> index a2e839d..4ce9862 100644
> --- a/Documentation/devicetree/bindings/gpio/gpio-davinci.txt
> +++ b/Documentation/devicetree/bindings/gpio/gpio-davinci.txt
> @@ -1,7 +1,7 @@
> -Davinci GPIO controller bindings
> +Davinci/Keystone GPIO controller bindings
>
> Required Properties:
> -- compatible: should be "ti,dm6441-gpio"
> +- compatible: should be "ti,dm6441-gpio", "ti,keystone-gpio"
>
> - reg: Physical base address of the controller and the size of memory mapped
> registers.
> diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
> index 7629b4f..d0f135d 100644
> --- a/drivers/gpio/gpio-davinci.c
> +++ b/drivers/gpio/gpio-davinci.c
> @@ -37,6 +37,8 @@ struct davinci_gpio_regs {
> u32 intstat;
> };
>
> +typedef struct irq_chip *(*gpio_get_irq_chip_cb_t)(unsigned int irq);
> +
> #define BINTEN 0x8 /* GPIO Interrupt Per-Bank Enable Register */
>
> #define chip2controller(chip) \
> @@ -413,6 +415,26 @@ static const struct irq_domain_ops davinci_gpio_irq_ops = {
> .xlate = irq_domain_xlate_onetwocell,
> };
>
> +static struct irq_chip *davinci_gpio_get_irq_chip(unsigned int irq)
> +{
> + static struct irq_chip_type gpio_unbanked;
> +
> + gpio_unbanked = *container_of(irq_get_chip(irq),
> + struct irq_chip_type, chip);
> +
> + return &gpio_unbanked.chip;
> +};
> +
> +static struct irq_chip *keystone_gpio_get_irq_chip(unsigned int irq)
> +{
> + static struct irq_chip gpio_unbanked;
> +
> + gpio_unbanked = *irq_get_chip(irq);
> + return &gpio_unbanked;
> +};
> +
> +static const struct of_device_id davinci_gpio_ids[];
> +
> /*
> * NOTE: for suspend/resume, probably best to make a platform_device with
> * suspend_late/resume_resume calls hooking into results of the set_wake()
> @@ -433,6 +455,18 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
> struct davinci_gpio_platform_data *pdata = dev->platform_data;
> struct davinci_gpio_regs __iomem *g;
> struct irq_domain *irq_domain = NULL;
> + const struct of_device_id *match;
> + struct irq_chip *irq_chip;
> + gpio_get_irq_chip_cb_t gpio_get_irq_chip;
> +
> + /*
> + * Use davinci_gpio_get_irq_chip by default to handle non DT cases
> + */
> + gpio_get_irq_chip = davinci_gpio_get_irq_chip;
> + match = of_match_device(of_match_ptr(davinci_gpio_ids),
> + dev);
> + if (match)
> + gpio_get_irq_chip = (gpio_get_irq_chip_cb_t)match->data;
>
> ngpio = pdata->ngpio;
> res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
> @@ -489,8 +523,6 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
> * IRQ mux conflicts; gpio_irq_type_unbanked() is only for GPIOs.
> */
> if (pdata->gpio_unbanked) {
> - static struct irq_chip_type gpio_unbanked;
> -
> /* pass "bank 0" GPIO IRQs to AINTC */
> chips[0].chip.to_irq = gpio_to_irq_unbanked;
> chips[0].gpio_irq = bank_irq;
> @@ -499,10 +531,9 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
>
> /* AINTC handles mask/unmask; GPIO handles triggering */
> irq = bank_irq;
> - gpio_unbanked = *container_of(irq_get_chip(irq),
> - struct irq_chip_type, chip);
> - gpio_unbanked.chip.name = "GPIO-AINTC";
> - gpio_unbanked.chip.irq_set_type = gpio_irq_type_unbanked;
> + irq_chip = gpio_get_irq_chip(irq);
> + irq_chip->name = "GPIO-AINTC";
> + irq_chip->irq_set_type = gpio_irq_type_unbanked;
>
> /* default trigger: both edges */
> g = gpio2regs(0);
> @@ -511,7 +542,7 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
>
> /* set the direct IRQs up to use that irqchip */
> for (gpio = 0; gpio < pdata->gpio_unbanked; gpio++, irq++) {
> - irq_set_chip(irq, &gpio_unbanked.chip);
> + irq_set_chip(irq, irq_chip);
> irq_set_handler_data(irq, &chips[gpio / 32]);
> irq_set_status_flags(irq, IRQ_TYPE_EDGE_BOTH);
> }
> @@ -554,7 +585,8 @@ done:
>
> #if IS_ENABLED(CONFIG_OF)
> static const struct of_device_id davinci_gpio_ids[] = {
> - { .compatible = "ti,dm6441-gpio", },
> + { .compatible = "ti,keystone-gpio", keystone_gpio_get_irq_chip},
> + { .compatible = "ti,dm6441-gpio", davinci_gpio_get_irq_chip},
> { /* sentinel */ },
> };
> MODULE_DEVICE_TABLE(of, davinci_gpio_ids);
>
^ permalink raw reply
* Re: [PATCH 3/7] IBM Akebono: Add support to the OHCI platform driver for PPC476GTR
From: Arnd Bergmann @ 2014-02-21 14:16 UTC (permalink / raw)
To: Alistair Popple
Cc: gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ
In-Reply-To: <1392964293-13687-4-git-send-email-alistair-Y4h6yKqj69EXC2x5gXVKYQ@public.gmane.org>
On Friday 21 February 2014 17:31:29 Alistair Popple wrote:
>
> +static const struct of_device_id ohci_of_match[] = {
> + { .compatible = "usb-ohci", },
> + {},
> +};
> +
> static const struct platform_device_id ohci_platform_table[] = {
> { "ohci-platform", 0 },
> { }
> @@ -198,6 +209,7 @@ static struct platform_driver ohci_platform_driver = {
> .owner = THIS_MODULE,
> .name = "ohci-platform",
> .pm = &ohci_platform_pm_ops,
> + .of_match_table = ohci_of_match,
> }
> };
>
>
Linux-next already has a patch to add an of_match_table in this driver,
using
static const struct of_device_id ohci_platform_ids[] = {
{ .compatible = "generic-ohci", },
{ }
};
I think you should just use that string on your platform.
Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH 1/7] IBM Akebono: Add a SDHCI platform driver
From: Arnd Bergmann @ 2014-02-21 14:14 UTC (permalink / raw)
To: Alistair Popple
Cc: linux-mmc-u79uwXL29TY76Z2rM5mHXA, cjb-2X9k7bc8m7Mdnm+yROfE0A,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ
In-Reply-To: <1392964293-13687-2-git-send-email-alistair-Y4h6yKqj69EXC2x5gXVKYQ@public.gmane.org>
On Friday 21 February 2014 17:31:27 Alistair Popple wrote:
>
> +config MMC_SDHCI_OF_476GTR
> + tristate "SDHCI OF support for the IBM PPC476GTR SoC"
> + depends on MMC_SDHCI_PLTFM
> + depends on PPC_OF
> + help
> + This selects the Secure Digital Host Controller Interface (SDHCI)
> + found on the PPC476GTR SoC.
> +
> + If you have a controller with this interface, say Y or M here.
> +
> + If unsure, say N.
Your driver doesn't actually do anything beyond what is in the common
sdhci-pltfm.c infrastructure. IMHO you really shoulnd't need a SoC
specific abstraction for it at all and instead add a generic
platform driver registration into sdhci-pltfm.c. I'd suggest
you use "generic-sdhci" (similar to what we do for usb-ohci and usb-ehci
now) as the compatible string and change your device tree to claim
compatibility with that and your soc-specific string.
Arnd
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: devicetree repository separation/migration
From: Sascha Hauer @ 2014-02-21 14:11 UTC (permalink / raw)
To: Frank Rowand
Cc: Jason Cooper, Grant Likely, Rob Herring, Ian Campbell,
pawel.moll-5wv7dgnIgG8, mark.rutland-5wv7dgnIgG8,
galak-sgV2jX0FEOL9JmXXK+q4OQ, rob-VoJi6FS/r0vR7s880joybQ,
devicetree-u79uwXL29TY76Z2rM5mHXA,
devicetree-spec-u79uwXL29TY76Z2rM5mHXA,
devicetree-compiler-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <5306A6C0.9000206-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
On Thu, Feb 20, 2014 at 05:07:12PM -0800, Frank Rowand wrote:
> On 2/17/2014 10:05 AM, Jason Cooper wrote:
> > All,
> >
> > At last weeks devicetree irc meeting, I took on the task of writing this
> > email. I'm a bit behind.
> >
> > One of the outcomes of the ARM/devicetree discussion at the 2013 Kernel
> > Summit was that we were going to hold off on separating the devicetree
> > from the Linux kernel tree. The primary reason for this was to get
> > through the backlog of patches.
> >
> > It's been several months, and we're seeing evidence of other projects
> > having difficulty keeping in sync with the kernel tree. Specifically,
> > barebox is having trouble syncing:
> >
> > http://list-archives.org/2014/02/07/barebox-lists-infradead-org/devicetree-maintenance-in-barebox/f/5820726136
>
> < snip >
>
> Sascha,
>
> (Directing this to you, because the devicetree-maintenance-in-barebox thread
> begins with an email from you.)
>
> I have read through the referenced thread, but do not yet understand the cause
> of the issues the barebox project is facing. What I got from the thread is
> that the barebox project maintains some devicetree changes in the project
> repository, and it is difficult to manage these changes as the upstream
> project (the Linux kernel) makes changes.
>
> What are the barebox changes to dts files?
Mostly mtd partitions and descriptions where barebox can find its
environment.
>
> Why are the changes not submitted upstream? (Or if they were submitted, why
> were they not accepted?)
The descriptions where to find the environment are obviously barebox
specific and not acceptable upstream. mtd partitions shouldn't be
upstream either since they should be changeable on a per project or even
per board basis.
As mentioned before we can put the changes into barebox specific dts
files which include the original upstream dts files. This way we can
keep the changes separated from the original files and don't have to
patch them.
>
> I'm not sure what else to ask to try to understand the issues for barebox. Is
> there anything else you can say to help me understand?
>
> How would moving the devicetree files to another repository (also external to
> the barebox project) resolve the issues for the barebox project?
When I start supporting a new board I start with porting the bootloader.
For doing so I create an initial dts for the board which is then part of
barebox. At some point barebox development is done, further work is done
in the kernel, so the dts is copied there. The graphics nodes are added
which are irrelevant for barebox. Along the way I find some bugs in
the dts which are relevant for barebox, so I have to sync the dts back
to barebox at some point.
When someone posts barebox patches for a new board I normally would have
to ask him to post the patches for Linux inclusion first, because
otherwise I will get conflicting devicetrees downstream in barebox
later when the board is ported to the kernel.
None of the above is magically solved when the dts files are external to
the kernel, it just simplifies the process. It would allow me to use
version control systems to do the sync rather than copying files back
and forth.
Ians dts repository is a good start, but it contains a complete kernel
history and this is not very suitable as a submodule for other projects.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
--
To unsubscribe from this list: send the line "unsubscribe devicetree-compiler" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH RFC] usb: gadget: Add xilinx axi usb2 device support
From: Michal Simek @ 2014-02-21 14:06 UTC (permalink / raw)
To: Mark Rutland
Cc: Felipe Balbi, Subbaraya Sundeep Bhatta, Greg Kroah-Hartman,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Subbaraya Sundeep Bhatta, devicetree@vger.kernel.org
In-Reply-To: <20140221135713.GB20449@e106331-lin.cambridge.arm.com>
[-- Attachment #1: Type: text/plain, Size: 1135 bytes --]
>> If we can point to standard interrupt description then please point me to
>> exact description you would like to see here and we can change it.
>
> Unfortunately I'm not aware of a generic interrupts document. I just
> don't see the point in each document listing interrupt-parent as a
> requiredp roeprty when it's not. That said this is a trivial detail and
> not really a blocker.
I agree with you that copying this part again and again is just problematic.
Time to time I see that IRQs doesn't need to be described too.
I am also not sure if kernel can work without interrupt-parent at all.
I expect that it won't work and because we have interrupt parent in every
node (which is generated) it is probably required in our setup.
As you said it is just trivial detail for me too.
Thanks,
Michal
--
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]
^ permalink raw reply
* Re: [PATCH RFC] usb: gadget: Add xilinx axi usb2 device support
From: Mark Rutland @ 2014-02-21 13:57 UTC (permalink / raw)
To: Michal Simek
Cc: Felipe Balbi, Subbaraya Sundeep Bhatta, Greg Kroah-Hartman,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Subbaraya Sundeep Bhatta, devicetree@vger.kernel.org
In-Reply-To: <5307576F.5050506@monstr.eu>
On Fri, Feb 21, 2014 at 01:41:03PM +0000, Michal Simek wrote:
> Hi Mark,
>
> On 02/21/2014 01:04 PM, Mark Rutland wrote:
> >
> > On Thu, Feb 20, 2014 at 06:23:13PM +0000, Felipe Balbi wrote:
> >> Hi,
> >>
> >> On Wed, Feb 19, 2014 at 03:10:45PM +0530, Subbaraya Sundeep Bhatta wrote:
> >>> This patch adds xilinx axi usb2 device driver support
> >>>
> >>> Signed-off-by: Subbaraya Sundeep Bhatta <sbhatta@xilinx.com>
> >>> ---
> >>> .../devicetree/bindings/usb/xilinx_usb.txt | 21 +
> >>> drivers/usb/gadget/Kconfig | 14 +
> >>> drivers/usb/gadget/Makefile | 1 +
> >>> drivers/usb/gadget/xilinx_udc.c | 2045 ++++++++++++++++++++
> >>> 4 files changed, 2081 insertions(+), 0 deletions(-)
> >>> create mode 100644 Documentation/devicetree/bindings/usb/xilinx_usb.txt
> >>> create mode 100644 drivers/usb/gadget/xilinx_udc.c
> >>>
> >>> diff --git a/Documentation/devicetree/bindings/usb/xilinx_usb.txt b/Documentation/devicetree/bindings/usb/xilinx_usb.txt
> >>> new file mode 100644
> >>> index 0000000..acf03ab
> >>> --- /dev/null
> >>> +++ b/Documentation/devicetree/bindings/usb/xilinx_usb.txt
> >>> @@ -0,0 +1,21 @@
> >>> +Xilinx AXI USB2 device controller
> >>> +
> >>> +Required properties:
> >>> +- compatible : Should be "xlnx,axi-usb2-device-4.00.a"
> >
> > Is "axi-usb2-device" the official device name?
>
> It is the name of IP which Xilinx have and we are using names in this format.
>
>
> >>> +- reg : Physical base address and size of the Axi USB2
> >>> + device registers map.
> >>> +- interrupts : Property with a value describing the interrupt
> >>> + number.
> >
> > Does the device only have a single interrupt?
>
> I believe so.
>
>
> >>> +- interrupt-parent : Must be core interrupt controller
> >
> > Is this strictly necessary?
>
> I am not sure what do you mean by that. If you mean that interrupt-parent
> can be written to the root of DTS file then we can setup system with more
> interrupt controllers that's why it is required.
At which point it's not a required property of the node...
> If we can point to standard interrupt description then please point me to
> exact description you would like to see here and we can change it.
Unfortunately I'm not aware of a generic interrupts document. I just
don't see the point in each document listing interrupt-parent as a
requiredp roeprty when it's not. That said this is a trivial detail and
not really a blocker.
Cheers,
Mark
^ permalink raw reply
* Re: [PATCH tty-next v2 4/4] Documentation: devicetree: add bindings documentation for bcm63xx-uart
From: Mark Rutland @ 2014-02-21 13:49 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Florian Fainelli, linux-serial@vger.kernel.org,
devicetree@vger.kernel.org, mbizon@freebox.fr, jogo@openwrt.org,
gregkh@linuxfoundation.org, gregory.0xf0@gmail.com
In-Reply-To: <3250738.VGSO94B75K@wuerfel>
On Fri, Feb 21, 2014 at 12:49:05PM +0000, Arnd Bergmann wrote:
> Two more comments:
>
> On Thursday 20 February 2014 10:15:54 Florian Fainelli wrote:
> > +- clock-names: should contain "periph" for the functional clock
>
> I think we should really start standardizing on the clock names more.
> We don't have any uart that calls its functional clock "periph" so
> far.
>
> How about naming it "fclk" or "uart"?
>
> I'd actually prefer making it an anonymous clock, but I know that
> will just trigger comments about what might happen if it turns
> out we need more than one clock for a future version of this device.
Yup ;)
I'm happy as long as we have a well-defined name for each clock input,
regardless of what those particular names might be.
Mark.
^ permalink raw reply
* Re: [PATCH RFC] usb: gadget: Add xilinx axi usb2 device support
From: Michal Simek @ 2014-02-21 13:41 UTC (permalink / raw)
To: Mark Rutland
Cc: Felipe Balbi, Subbaraya Sundeep Bhatta, Greg Kroah-Hartman,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Subbaraya Sundeep Bhatta, devicetree@vger.kernel.org
In-Reply-To: <20140221120454.GD8783@e106331-lin.cambridge.arm.com>
[-- Attachment #1: Type: text/plain, Size: 3598 bytes --]
Hi Mark,
On 02/21/2014 01:04 PM, Mark Rutland wrote:
>
> On Thu, Feb 20, 2014 at 06:23:13PM +0000, Felipe Balbi wrote:
>> Hi,
>>
>> On Wed, Feb 19, 2014 at 03:10:45PM +0530, Subbaraya Sundeep Bhatta wrote:
>>> This patch adds xilinx axi usb2 device driver support
>>>
>>> Signed-off-by: Subbaraya Sundeep Bhatta <sbhatta@xilinx.com>
>>> ---
>>> .../devicetree/bindings/usb/xilinx_usb.txt | 21 +
>>> drivers/usb/gadget/Kconfig | 14 +
>>> drivers/usb/gadget/Makefile | 1 +
>>> drivers/usb/gadget/xilinx_udc.c | 2045 ++++++++++++++++++++
>>> 4 files changed, 2081 insertions(+), 0 deletions(-)
>>> create mode 100644 Documentation/devicetree/bindings/usb/xilinx_usb.txt
>>> create mode 100644 drivers/usb/gadget/xilinx_udc.c
>>>
>>> diff --git a/Documentation/devicetree/bindings/usb/xilinx_usb.txt b/Documentation/devicetree/bindings/usb/xilinx_usb.txt
>>> new file mode 100644
>>> index 0000000..acf03ab
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/usb/xilinx_usb.txt
>>> @@ -0,0 +1,21 @@
>>> +Xilinx AXI USB2 device controller
>>> +
>>> +Required properties:
>>> +- compatible : Should be "xlnx,axi-usb2-device-4.00.a"
>
> Is "axi-usb2-device" the official device name?
It is the name of IP which Xilinx have and we are using names in this format.
>>> +- reg : Physical base address and size of the Axi USB2
>>> + device registers map.
>>> +- interrupts : Property with a value describing the interrupt
>>> + number.
>
> Does the device only have a single interrupt?
I believe so.
>>> +- interrupt-parent : Must be core interrupt controller
>
> Is this strictly necessary?
I am not sure what do you mean by that. If you mean that interrupt-parent
can be written to the root of DTS file then we can setup system with more
interrupt controllers that's why it is required.
If we can point to standard interrupt description then please point me to
exact description you would like to see here and we can change it.
>>> +- xlnx,include-dma : Must be 1 or 0 based on whether DMA is included
>>> + in IP or not.
>
> Perhaps xlnx,has-builtin-dma would better describe this?
No opinion.
>>> +
>>> +Example:
>>> + axi-usb2-device@42e00000 {
>>> + compatible = "xlnx,axi-usb2-device-4.00.a";
>>> + interrupt-parent = <0x1>;
>>> + interrupts = <0x0 0x39 0x1>;
>>> + reg = <0x42e00000 0x10000>;
>>> + xlnx,include-dma = <0x1>;
>>> + };
>>> +
>>
>> you need to Cc devicetree@vger.kernel.org for this.
>
> Cheers Filipe; thanks for adding us to Cc :)
>
Sundeep with CC devicetree list in next patch version.
>>> + /* Map the registers */
>>> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>> + udc->base_address = devm_ioremap_nocache(&pdev->dev, res->start,
>>> + resource_size(res));
>>
>> use devm_ioremap_resource() instead.
>
> Also, res might be NULL. You should check that before dereferencing it.
yes it is necessary for both cases with devm_ioremap_nocache
or with devm_ioremap_resource.
Thanks,
Michal
--
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]
^ permalink raw reply
* Re: [PATCH v4 1/7] drivers: of: add initialization code for reserved memory
From: Grant Likely @ 2014-02-21 13:38 UTC (permalink / raw)
To: Marek Szyprowski, linux-kernel, linux-arm-kernel, linaro-mm-sig,
devicetree, linux-doc
Cc: Benjamin Herrenschmidt, Arnd Bergmann, Michal Nazarewicz,
Tomasz Figa, Sascha Hauer, Laura Abbott, Rob Herring,
Olof Johansson, Pawel Moll, Mark Rutland, Stephen Warren,
Ian Campbell, Tomasz Figa, Kumar Gala, Nishanth Peethambaran,
Marc, Josh Cartwright, Catalin Marinas, Will Deacon,
Paul Mackerras
In-Reply-To: <530731DC.2000400@samsung.com>
On Fri, 21 Feb 2014 12:00:44 +0100, Marek Szyprowski <m.szyprowski@samsung.com> wrote:
> Hello,
>
> On 2014-02-20 15:01, Grant Likely wrote:
> > On Thu, 20 Feb 2014 11:52:41 +0100, Marek Szyprowski <m.szyprowski@samsung.com> wrote:
> > > This patch adds device tree support for contiguous and reserved memory
> > > regions defined in device tree.
> > >
> > > Large memory blocks can be reliably reserved only during early boot.
> > > This must happen before the whole memory management subsystem is
> > > initialized, because we need to ensure that the given contiguous blocks
> > > are not yet allocated by kernel. Also it must happen before kernel
> > > mappings for the whole low memory are created, to ensure that there will
> > > be no mappings (for reserved blocks) or mapping with special properties
> > > can be created (for CMA blocks). This all happens before device tree
> > > structures are unflattened, so we need to get reserved memory layout
> > > directly from fdt.
> > >
> > > Later, those reserved memory regions are assigned to devices on each
> > > device structure initialization.
> > >
> > > Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> > > [joshc: rework to implement new DT binding, provide mechanism for
> > > plugging in new reserved-memory node handlers via
> > > RESERVEDMEM_OF_DECLARE]
> > > Signed-off-by: Josh Cartwright <joshc@codeaurora.org>
> > > [mszyprow: added generic memory reservation code, refactored code to
> > > put it directly into fdt.c]
> > > Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> > > ---
> > > drivers/of/Kconfig | 6 +
> > > drivers/of/Makefile | 1 +
> > > drivers/of/fdt.c | 145 ++++++++++++++++++
> > > drivers/of/of_reserved_mem.c | 296 +++++++++++++++++++++++++++++++++++++
> > > drivers/of/platform.c | 7 +
> > > include/asm-generic/vmlinux.lds.h | 11 ++
> > > include/linux/of_reserved_mem.h | 65 ++++++++
> > > 7 files changed, 531 insertions(+)
> > > create mode 100644 drivers/of/of_reserved_mem.c
> > > create mode 100644 include/linux/of_reserved_mem.h
> >
> > Hi Marek,
> >
> > There's a lot of moving parts in this patch. Can you split the patch up a bit please. There are parts that I'm not entierly comfortable with yet and it will help reviewing them if they are added separately. For instance, the attaching regions to devices is something that I want to have some discussion about, but the core reserving static ranges I think is pretty much ready to be merged. I can merge the later while still debating the former if they are split.
> >
> > I would recommend splitting into four:
> > 1) reservation of static regions without the support code for referencing them later
> > 2) code to also do dynamic allocations of reserved regions - again without any driver references
> > 3) add hooks to reference specific regions.
> > 4) hooks into drivers/of/platform.c for wiring into the driver model.
> >
> > Can you also make the binding doc the first patch?
>
> Ok, I will slice the patch into 4 pieces.
> >
> > <off topic> Wow, the flattree parsing code has to be really verbose. We really need better
> > flat tree parsing functions and helpers.
>
> Yes, parsing fdt is a real pain, but please don't ask me to implement
> all the
> helpers to make it easier together with this patch. I (and probably other
> developers) would really like to get this piece merged asap.
I won't. Mostly I was thinking out loud.
> > > + for (i = __reservedmem_of_table; i < &__rmem_of_table_sentinel; i++) {
> > > + reservedmem_of_init_fn initfn = i->data;
> > > + const char *compat = i->compatible;
> > > +
> > > + if (!of_flat_dt_is_compatible(rmem->fdt_node, compat))
> > > + continue;
> >
> > What if two entries both match the compatible list? Ideally score would
> > be taken into account. (I won't block on this issue, it can be a future
> > enhancement)
>
> If two entries have same compatible value they will be probed in the order
> of presence in the kernel binary. The return value is checked and the next
> one is being tried if init fails for the given function. The provided code
> already makes use of this feature. Both DMA coherent and CMA use
> "shared-dma-pool" compatible. DMA coherent init fails if 'reusable'
> property has been found. On the other hand, CMA fails initialization if
> 'reusable' property is missing. Frankly I would like to change standard
> DMA coherent compatible value to 'dma-pool' and keep 'shared-dma-pool'
> only for CMA, but I've implemented it the way it has been described in
> your binding documentation.
My binding document isn't gospel and it hasn't been merged yet. Reply to
the binding patch and make your argument for the change.
g.
^ permalink raw reply
* Re: [PATCH 1/1] ARM: Exynos: Add generic compatible string
From: Tomasz Figa @ 2014-02-21 13:18 UTC (permalink / raw)
To: Sachin Kamat, Arnd Bergmann
Cc: linux-arm-kernel, Mark Rutland, devicetree@vger.kernel.org,
Kukjin Kim, Ian Campbell, Rob Herring, Grant Likely,
linux-samsung-soc, Olof Johansson
In-Reply-To: <CAK9yfHyWG1ac6isTRSB3VWfxER9cSuDJHwY3b7svyEk9EozpWQ@mail.gmail.com>
On 21.02.2014 07:08, Sachin Kamat wrote:
> On 20 February 2014 23:18, Arnd Bergmann <arnd@arndb.de> wrote:
>> On Thursday 20 February 2014 18:34:23 Tomasz Figa wrote:
>>> On 20.02.2014 18:00, Arnd Bergmann wrote:
>>>>> Of course nothing stops you from retaining more specific compatible
>>>>> strings. In fact, this is probably the most appropriate solution,
>>>>> because in future you might find out that certain SoCs need some special
>>>>> differentiation, e.g. same ID value on two SoCs.
>>>>>
>>>>> So, to apply this to our case, our Exynos 5250 based Arndale board would
>>>>> be changed from
>>>>>
>>>>> compatible = "insignal,arndale", "samsung,exynos5260";
>>>>>
>>>>> to
>>>>>
>>>>> compatible = "insignal,arndale", "samsung,exynos5260", "samsung,exynos";
>>>>
>>>> Right, this would make sense.
>>>>
>>>>> Now, the board file will be able to match simply by "samsung,exynos"
>>>>> compatible string and SoC-specific code in mach-exynos (hopefully none
>>>>> after it gets cleaned up fully) will use soc_is_exynos*() macros (what
>>>>> AFAIK it is already doing at the moment).
>>>>
>>>> On principle, I would not take things out of the match list, if that
>>>> would break booting with old DT file that don't list "samsung,exynos"
>>>> as compatible. But for new SoCs that would work.
>>>
>>> My proposal was about simply adding a fully generic string, without
>>> removing the specific ones. For already supported SoCs this is pretty
>>> obvious, as existing DTBs would not have this generic string listed. But
>>> the specific strings should be also present in DTSes of new SoCs, even
>>> if not recognized by the kernel, to make sure that in future any
>>> SoC-specific quirks could be easily handled.
>>
>> Yes, that's ideal.
>>
>>>> Using soc_is_exynos*() too much of course also isn't good. A lot of
>>>> the things tested for should probably be checked from individual DT
>>>> properties, but again we have to find the right balance. I wouldn't
>>>> mind getting rid of the soc_is_exynos*() macros completely, because
>>>> a) we can't use them in device drivers
>>>> b) all platform code is supposed to be in drivers
>>>> c) both rules are enforced for arm64
>>>
>>> I fully agree. As I said, after cleaning up mach-exynos/ there should be
>>> no more code left using soc_is_*() macros. Ideally, the whole
>>> mach-exynos/ should collapse into a single, trivial file, with
>>> everything done in dedicated drivers.
>>
>> Right.
>
> Now that we have a broader agreement on this, I think we can go ahead with the
> following steps as an initial approach:
> 1. Have a common machine file for both exynos4 and 5 files, mach-exynos-dt.c.
> 2. Introduce a generic compatible string "samsung,exynos".
> 3. Append this to the compatible property list for existing boards.
>
> If this plan looks OK, I can send across patches doing this.
>
Looks good. I would also merge common.c with this resulting
mach-exynos-dt.c, as it would be the only user of the code there.
Best regards,
Tomasz
^ permalink raw reply
* [PATCH v2] dt: platform driver: Fill the resources before probe and defer if needed
From: Jean-Jacques Hiblot @ 2014-02-21 13:18 UTC (permalink / raw)
To: grant.likely, gregkh, robh+dt
Cc: gregory.clement, devicetree, linux-kernel, linux-arm-kernel,
Jean-Jacques Hiblot
In-Reply-To: <20140220153042.DF053C4050F@trevor.secretlab.ca>
The goal of this patch is to allow drivers to be probed even if at the time of
the DT parsing some of their ressources are not available yet.
In the current situation, the resource of a platform device are filled from the
DT at the time the device is created (of_device_alloc()). The drawbackof this
is that a device sitting close to the top of the DT (ahb for example) but
depending on ressources that are initialized later (IRQ domain dynamically
created for example) will fail to probe because the ressources don't exist
at this time.
This patch fills the resource structure only before the device is probed and
will defer the probe if the resource are not available yet.
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
Reviewed-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
---
Hi Grant,
I reworked the patch as you proposed. To keep the overhead minimum, nirq and
nreg are computed only the first time.
In this implementation, only the missing IRQ ressources are re-tried for. It could
easily be changed to re-parse all the IRQs though (replace if (!res->flags)
with if ((!res->flags) || (res->flags & IORESOURCE_IRQ)).
drivers/base/platform.c | 5 +++
drivers/of/platform.c | 100 +++++++++++++++++++++++++++++++++-----------
include/linux/of_platform.h | 10 +++++
3 files changed, 90 insertions(+), 25 deletions(-)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index bc78848..cee9b8d 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -481,6 +481,10 @@ static int platform_drv_probe(struct device *_dev)
struct platform_device *dev = to_platform_device(_dev);
int ret;
+ ret = of_platform_device_prepare(dev);
+ if (ret)
+ goto error;
+
if (ACPI_HANDLE(_dev))
acpi_dev_pm_attach(_dev, true);
@@ -488,6 +492,7 @@ static int platform_drv_probe(struct device *_dev)
if (ret && ACPI_HANDLE(_dev))
acpi_dev_pm_detach(_dev, true);
+error:
if (drv->prevent_deferred_probe && ret == -EPROBE_DEFER) {
dev_warn(_dev, "probe deferral not supported\n");
ret = -ENXIO;
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 404d1da..a4e2602 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -141,36 +141,11 @@ struct platform_device *of_device_alloc(struct device_node *np,
struct device *parent)
{
struct platform_device *dev;
- int rc, i, num_reg = 0, num_irq;
- struct resource *res, temp_res;
dev = platform_device_alloc("", -1);
if (!dev)
return NULL;
- /* count the io and irq resources */
- if (of_can_translate_address(np))
- while (of_address_to_resource(np, num_reg, &temp_res) == 0)
- num_reg++;
- num_irq = of_irq_count(np);
-
- /* Populate the resource table */
- if (num_irq || num_reg) {
- res = kzalloc(sizeof(*res) * (num_irq + num_reg), GFP_KERNEL);
- if (!res) {
- platform_device_put(dev);
- return NULL;
- }
-
- dev->num_resources = num_reg + num_irq;
- dev->resource = res;
- for (i = 0; i < num_reg; i++, res++) {
- rc = of_address_to_resource(np, i, res);
- WARN_ON(rc);
- }
- WARN_ON(of_irq_to_resource_table(np, res, num_irq) != num_irq);
- }
-
dev->dev.of_node = of_node_get(np);
#if defined(CONFIG_MICROBLAZE)
dev->dev.dma_mask = &dev->archdata.dma_mask;
@@ -233,6 +208,81 @@ static struct platform_device *of_platform_device_create_pdata(
return dev;
}
+static int of_reg_count(struct device_node *np)
+{
+ int nreg = 0;
+ if (of_can_translate_address(np)) {
+ struct resource temp_res;
+ while (of_address_to_resource(np, nreg, &temp_res) == 0)
+ nreg++;
+ }
+ return nreg;
+}
+
+int of_platform_device_prepare(struct platform_device *dev)
+{
+ struct device_node *np;
+ int i, irq_index;
+ struct resource *res;
+
+ /*
+ * This function applies only devices described in the DT.
+ * Other platform devices have their ressources already populated.
+ */
+ np = dev->dev.of_node;
+ if (!np)
+ return 0;
+
+ /* Populate the resource table */
+ if (!dev->resource) {
+ int rc, nreg = 0, nirq;
+ /* count the io and irq resources */
+ nreg = of_reg_count(np);
+ nirq = of_irq_count(np);
+
+ if (!nirq && !nreg)
+ return 0;
+
+ res = kzalloc(sizeof(*res) * (nirq + nreg), GFP_KERNEL);
+ if (!res)
+ return -ENOMEM;
+
+ dev->resource = res;
+ dev->num_resources = nreg + nirq;
+
+ for (i = 0; i < nreg; i++, res++) {
+ rc = of_address_to_resource(np, i, res);
+ if (WARN_ON(rc)) {
+ /* THIS IS BAD; don't try to defer probing */
+ dev->num_resources = 0;
+ dev->resource = NULL;
+ kfree(res);
+ return rc;
+ }
+ }
+
+ if (!rc && of_irq_to_resource_table(np, res, nirq) != nirq) {
+ /* IRQ controller is yet available. defer probing */
+ return -EPROBE_DEFER;
+ }
+
+ return 0;
+ }
+
+ /* See which IRQ resources need to be redone */
+ irq_index = 0;
+ for (i = 0, res = dev->resource; i < dev->num_resources; i++, res++) {
+ if (!res->flags) {
+ if (!of_irq_to_resource(np, irq_index, res))
+ return -EPROBE_DEFER;
+ irq_index++;
+ } else if (res->flags & IORESOURCE_IRQ)
+ irq_index++;
+ }
+ return 0;
+}
+EXPORT_SYMBOL(of_platform_device_prepare);
+
/**
* of_platform_device_create - Alloc, initialize and register an of_device
* @np: pointer to node to create device for
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
index 05cb4a9..4e487ff 100644
--- a/include/linux/of_platform.h
+++ b/include/linux/of_platform.h
@@ -53,6 +53,16 @@ struct of_dev_auxdata {
extern const struct of_device_id of_default_bus_match_table[];
+/* Populate the resource for a platform device */
+#ifdef CONFIG_OF
+int of_platform_device_prepare(struct platform_device *dev);
+#else
+static inline int of_platform_device_prepare(
+ struct platform_device *dev)
+{
+ return 0;
+}
+#endif
/* Platform drivers register/unregister */
extern struct platform_device *of_device_alloc(struct device_node *np,
const char *bus_id,
--
1.9.0
^ permalink raw reply related
* Re: [PATCH tty-next v2 4/4] Documentation: devicetree: add bindings documentation for bcm63xx-uart
From: Arnd Bergmann @ 2014-02-21 12:49 UTC (permalink / raw)
To: Florian Fainelli
Cc: linux-serial, devicetree, mbizon, jogo, gregkh, mark.rutland,
gregory.0xf0
In-Reply-To: <1392920154-3642-5-git-send-email-f.fainelli@gmail.com>
Two more comments:
On Thursday 20 February 2014 10:15:54 Florian Fainelli wrote:
> +- clock-names: should contain "periph" for the functional clock
I think we should really start standardizing on the clock names more.
We don't have any uart that calls its functional clock "periph" so
far.
How about naming it "fclk" or "uart"?
I'd actually prefer making it an anonymous clock, but I know that
will just trigger comments about what might happen if it turns
out we need more than one clock for a future version of this device.
> +Example:
> +
> +serial0: uart@600 {
> + compatible = "brcm,bcm6345-uart";
> + reg = <0x600 0x1b>;
> + interrupts = <GIC_SPI 32 0>;
> + clocks = <&periph_clk>;
> + clock-names = "periph";
> +};
The device name for a uart is "serial" by convention, not "uart",
so better make this serial@600.
Arnd
^ permalink raw reply
* Re: [PATCH v10 01/15] usb: doc: phy-mxs: Add more compatible strings
From: Mark Rutland @ 2014-02-21 12:38 UTC (permalink / raw)
To: Peter Chen
Cc: balbi@ti.com, shawn.guo@linaro.org, robh+dt@kernel.org,
grant.likely@linaro.org, Pawel Moll,
alexander.shishkin@linux.intel.com, linux-usb@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, festevam@gmail.com,
marex@denx.de, kernel@pengutronix.de, m.grzeschik@pengutronix.de,
Frank.Li@freescale.com, gregkh@linuxfoundation.org,
devicetree@vger.kernel.org, linux-doc@vger.kernel.org
In-Reply-To: <5e4d795b507a4ea7b9faa69dd05148c4@BL2PR03MB226.namprd03.prod.outlook.com>
On Fri, Feb 21, 2014 at 09:40:29AM +0000, Peter Chen wrote:
>
> > >
> > > Required properties:
> > > -- compatible: Should be "fsl,imx23-usbphy"
> > > +- compatible: "fsl,imx23-usbphy" for imx23 and imx28, "fsl,imx6q-
> > usbphy"
> > > + for imx6dq and imx6dl, "fsl,imx6sl-usbphy" for imx6sl
> >
> > Minor nit, but could we restructure this as something like the following,
> > with each string on a new line:
> >
> > - compatible: should contain:
> > * "fsl,imx23-usbphy" for imx23 and imx28
> > * "fsl,imx6q-usbphy" for imx6dq and imx6dl
> > * "fsl,imx6sl-usbphy" for imx6sl
> >
> > It makes it a bit easier to read.
>
> Thanks, will change like above.
>
> >
> > I see the existing "fsl,imx23-usbphy" is used as a fallback for
> > "fsl,imx28-usbphy", "fsl,imx6q-usbphy", and "fsl,imx6sl-usbphy" in
> > existing DTs.
> >
> > Is this expected going forward? It might be worth mentioning.
> >
>
> These SoCs used the same FSL imx PHY, but different versions.
> imx23/imx28 are the first version, more improvements are at
> later SoCs (like imx6x) version. Keep "fsl,imx23-usbphy" at
> imx6 dts will be user know it is from imx23's. If you think
> it does not need, I can delete "fsl,imx23-usbphy" from imx6 dts.
I'm not arguing to remove it, I'm suggesting it might be worth
mentioning that it's not mutually exclusive, and can be a fallback for
the other strings.
Cheers,
Mark.
^ permalink raw reply
* Re: [PATCH 1/2] usb: dwc3: core: continue probing if usb phy library returns -ENODEV/-ENXIO
From: Roger Quadros @ 2014-02-21 12:29 UTC (permalink / raw)
To: Kishon Vijay Abraham I, Heikki Krogerus, Felipe Balbi
Cc: george.cherian, devicetree, linux-doc, linux-kernel, linux-omap,
linux-arm-kernel, linux-usb
In-Reply-To: <5307459D.9080707@ti.com>
On 02/21/2014 02:25 PM, Kishon Vijay Abraham I wrote:
> Hi Roger,
>
> On Wednesday 19 February 2014 06:07 PM, Roger Quadros wrote:
>> Hi,
>>
>> On 02/12/2014 11:46 AM, Kishon Vijay Abraham I wrote:
>>> On Wednesday 29 January 2014 08:17 PM, Heikki Krogerus wrote:
>>>> Hi,
>>>>
>>>> On Tue, Jan 28, 2014 at 10:30:36AM -0600, Felipe Balbi wrote:
>>>>> On Tue, Jan 28, 2014 at 05:32:30PM +0200, Heikki Krogerus wrote:
>>>>>> On Mon, Jan 27, 2014 at 10:05:20AM -0600, Felipe Balbi wrote:
>>>>>> For the controller drivers the PHYs are just a resource like any
>>>>>> other. The controller drivers can't have any responsibility of
>>>>>> them. They should not care if PHY drivers are available for them or
>>>>>> not, or even if the PHY framework is available or not.
>>>>>
>>>>> huh? If memory isn't available you don't continue probing, right ? If
>>>>> your IORESOURCE_MEM is missing, you also don't continue probing, if your
>>>>> IRQ line is missing, you bail too. Those are also nothing but resources
>>>>> to the driver, what you're asking here is to treat PHY as a _different_
>>>>> resource; which might be fine, but we need to make sure we don't
>>>>> continue probing when a PHY is missing in a platform that certainly
>>>>> needs a PHY.
>>>>
>>>> Yes, true. In my head I was comparing the PHY only to resources like
>>>> gpios, clocks, dma channels, etc. that are often optional to the
>>>> drivers.
>>>>
>>>>>>>>> But I really want to see the argument against using no-op. As far as I
>>>>>>>>> could see, everybody needs a PHY driver one way or another, some
>>>>>>>>> platforms just haven't sent any PHY driver upstream and have their own
>>>>>>>>> hacked up solution to avoid using the PHY layer.
>>>>>>>>
>>>>>>>> Not true in our case. Platforms using Intel's SoCs and chip sets may
>>>>>>>> or may not have controllable USB PHY. Quite often they don't. The
>>>>>>>> Baytrails have usually ULPI PHY for USB2, but that does not mean they
>>>>>>>> provide any vendor specific functions or any need for a driver in any
>>>>>>>> case.
>>>>>>>
>>>>>>> that's different from what I heard.
>>>>>>
>>>>>> I don't know where you got that impression, but it's not true. The
>>>>>> Baytrail SoCs for example don't have internal USB PHYs, which means
>>>>>> the manufacturers using it can select what they want. So we have
>>>>>> boards where PHY driver(s) is needed and boards where it isn't.
>>>>>
>>>>> alright, that explains it ;-) So you have external USB2 and USB3 PHYs ?
>>>>> You have an external PIPE3 interface ? That's quite an achievement,
>>>>> kudos to your HW designers. Getting timing closure on PIPE3 is a
>>>>> difficult task.
>>>>
>>>> No, only the USB2 PHY is external. I'm giving you wrong information,
>>>> I'm sorry about that. Need to concentrate on what I'm writing.
>>>>
>>>> <snip>
>>>>
>>>>>> This is really good to get. We have some projects where we are dealing
>>>>>> with more embedded environments, like IVI, where the kernel should be
>>>>>> stripped of everything useless. Since the PHYs are autonomous, we
>>>>>> should be able to disable the PHY libraries/frameworks.
>>>>>
>>>>> hmmm, in that case it's a lot easier to treat. We can use
>>>>> ERR_PTR(-ENXIO) as an indication that the framework is disabled, or
>>>>> something like that.
>>>>>
>>>>> The difficult is really reliably supporting e.g. OMAP5 (which won't work
>>>>> without a PHY) and your BayTrail with autonomous PHYs. What can we use
>>>>> as an indication ?
>>>>
>>>> OMAP has it's own glue driver, so shouldn't it depend on the PHY
>>>> layer?
>>>
>>> right, but the PHY is connected to the dwc3 core and not to the glue.
>>>>
>>>>> I mean, I need to know that a particular platform depends on a PHY
>>>>> driver before I decide to return -EPROBE_DEFER or just assume the PHY
>>>>> isn't needed ;-)
>>>>
>>>> I don't think dwc3 (core) should care about that. The PHY layer needs
>>>> to tell us that. If the PHY driver that the platform depends is not
>>>> available yet, the PHY layer returns -EPROBE_DEFER and dwc3 ends up
>>>> returning -EPROBE_DEFER.
>>>
>>> I don't think the PHY layer can 'reliably' tell if PHY driver is available or
>>> not. Consider when the phy_provider_register fails, there is no way to know if
>>> PHY driver is available or not. There are a few cases where PHY layer returns
>>> -EPROBE_DEFER but none of them can tell for sure that PHY driver is either
>>> available and failed or not available at all. It would be best for us to leave
>>> that to the platforms if we want to be sure if the platform needs a PHY or not.
>>>
>>
>> Just to summarize this thread on what we need
>
> Thanks for summarizing.
>>
>> 1) dwc3 core shouldn't worry about platform specific stuff i.e. PHY needed or not.
>> It should be as generic as possible.
>>
>> 2) dwc3 core should continue probe even if PHY layer is not enabled, as not all platforms need it.
>>
>> 3) dwc3 core should continue probe if PHY device is not available. (-ENODEV?)
>>
>> 4) dwc3 core should error out on any error condition if PHY device is available and caused some error,
>> e.g. init error.
>>
>> 5) dwc3 core should return EPROBE_DEFER if PHY device is available but device driver is not yet loaded.
>>
>> 6) platform glue should do the necessary sanity checks for availability of all resources like PHY device, PHY layer, etc, before populating the dwc3 device. e.g. in OMAP5 case we could check if both usb2 and usb3 PHY
>> nodes are available in the DT and PHY layer is enabled, from dwc3-omap.c? In J6 case we could check that at least usb2 phy node is there for the High-Speed only controller, and so on.
>
> The PHY is connected to the dwc3 core. So I'm not sure if we should be doing
> checks for PHY in the glue layer.
Sorry, I didn't get you. My reasoning was that since OMAP platform has this strict requirement of requiring
explicit PHY control in order to work, we must do the sanity checks in OMAP specific code and not in the dwc3 core code. It has nothing to do with how hardware is laid out.
What alternative do you suggest otherwise?
cheers,
-roger
^ permalink raw reply
* [PATCH v5 11/11] powerpc: add support for reserved memory defined by device tree
From: Marek Szyprowski @ 2014-02-21 12:25 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel, linaro-mm-sig, devicetree,
linux-doc
Cc: Marek Szyprowski, Benjamin Herrenschmidt, Arnd Bergmann,
Michal Nazarewicz, Grant Likely, Tomasz Figa, Sascha Hauer,
Laura Abbott, Rob Herring, Olof Johansson, Pawel Moll,
Mark Rutland, Stephen Warren, Ian Campbell, Tomasz Figa,
Kumar Gala, Nishanth Peethambaran, Marc, Josh Cartwright,
Catalin Marinas, Will Deacon, Paul Mackerras
In-Reply-To: <1392985527-6260-1-git-send-email-m.szyprowski@samsung.com>
Enable reserved memory initialization from device tree.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
arch/powerpc/Kconfig | 1 +
arch/powerpc/kernel/prom.c | 3 +++
2 files changed, 4 insertions(+)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 957bf344c0f5..3b6617fed8fc 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -90,6 +90,7 @@ config PPC
select BINFMT_ELF
select OF
select OF_EARLY_FLATTREE
+ select OF_RESERVED_MEM
select HAVE_FTRACE_MCOUNT_RECORD
select HAVE_DYNAMIC_FTRACE
select HAVE_FUNCTION_TRACER
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index f58c0d3aaeb4..591986215801 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -33,6 +33,7 @@
#include <linux/irq.h>
#include <linux/memblock.h>
#include <linux/of.h>
+#include <linux/of_fdt.h>
#include <asm/prom.h>
#include <asm/rtas.h>
@@ -588,6 +589,8 @@ static void __init early_reserve_mem_dt(void)
memblock_reserve(base, size);
}
}
+
+ early_init_fdt_scan_reserved_mem();
}
static void __init early_reserve_mem(void)
--
1.7.9.5
^ permalink raw reply related
* [PATCH v5 10/11] arm64: add support for reserved memory defined by device tree
From: Marek Szyprowski @ 2014-02-21 12:25 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel, linaro-mm-sig, devicetree,
linux-doc
Cc: Marek Szyprowski, Benjamin Herrenschmidt, Arnd Bergmann,
Michal Nazarewicz, Grant Likely, Tomasz Figa, Sascha Hauer,
Laura Abbott, Rob Herring, Olof Johansson, Pawel Moll,
Mark Rutland, Stephen Warren, Ian Campbell, Tomasz Figa,
Kumar Gala, Nishanth Peethambaran, Marc, Josh Cartwright,
Catalin Marinas, Will Deacon, Paul Mackerras
In-Reply-To: <1392985527-6260-1-git-send-email-m.szyprowski@samsung.com>
Enable reserved memory initialization from device tree.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
arch/arm64/Kconfig | 1 +
arch/arm64/mm/init.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 27bbcfc7202a..6abf15407dca 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -43,6 +43,7 @@ config ARM64
select NO_BOOTMEM
select OF
select OF_EARLY_FLATTREE
+ select OF_RESERVED_MEM
select PERF_USE_VMALLOC
select POWER_RESET
select POWER_SUPPLY
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index d0b4c2efda90..3fb8d50dfdaa 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -160,6 +160,7 @@ void __init arm64_memblock_init(void)
memblock_reserve(base, size);
}
+ early_init_fdt_scan_reserved_mem();
dma_contiguous_reserve(0);
memblock_allow_resize();
--
1.7.9.5
^ permalink raw reply related
* [PATCH v5 09/11] arm: add support for reserved memory defined by device tree
From: Marek Szyprowski @ 2014-02-21 12:25 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel, linaro-mm-sig, devicetree,
linux-doc
Cc: Mark Rutland, Benjamin Herrenschmidt, Tomasz Figa, Will Deacon,
Tomasz Figa, Paul Mackerras, Marek Szyprowski, Arnd Bergmann,
Josh Cartwright, Catalin Marinas, Grant Likely, Laura Abbott,
Ian Campbell, Pawel Moll, Stephen Warren, Sascha Hauer,
Michal Nazarewicz, Marc, Nishanth Peethambaran, Rob Herring,
Kumar Gala, Olof Johansson
In-Reply-To: <1392985527-6260-1-git-send-email-m.szyprowski@samsung.com>
Enable reserved memory initialization from device tree.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
arch/arm/Kconfig | 1 +
arch/arm/mm/init.c | 2 ++
2 files changed, 3 insertions(+)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index e25419817791..d0262bea8020 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1918,6 +1918,7 @@ config USE_OF
select IRQ_DOMAIN
select OF
select OF_EARLY_FLATTREE
+ select OF_RESERVED_MEM
help
Include support for flattened device tree machine descriptions.
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 804d61566a53..2a77ba8796ae 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -323,6 +323,8 @@ void __init arm_memblock_init(struct meminfo *mi,
if (mdesc->reserve)
mdesc->reserve();
+ early_init_fdt_scan_reserved_mem();
+
/*
* reserve memory for DMA contigouos allocations,
* must come from DMA area inside low memory
--
1.7.9.5
^ permalink raw reply related
* [PATCH v5 08/11] drivers: dma-contiguous: add initialization from device tree
From: Marek Szyprowski @ 2014-02-21 12:25 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel, linaro-mm-sig, devicetree,
linux-doc
Cc: Marek Szyprowski, Benjamin Herrenschmidt, Arnd Bergmann,
Michal Nazarewicz, Grant Likely, Tomasz Figa, Sascha Hauer,
Laura Abbott, Rob Herring, Olof Johansson, Pawel Moll,
Mark Rutland, Stephen Warren, Ian Campbell, Tomasz Figa,
Kumar Gala, Nishanth Peethambaran, Marc, Josh Cartwright,
Catalin Marinas, Will Deacon, Paul Mackerras
In-Reply-To: <1392985527-6260-1-git-send-email-m.szyprowski@samsung.com>
Refactor internal dma_contiguous_init_reserved_mem() function, which
creates CMA area from previously reserved memory region and add support
for handling 'shared-dma-pool' reserved-memory device tree nodes.
Based on previous code provided by Josh Cartwright <joshc@codeaurora.org>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
drivers/base/dma-contiguous.c | 130 ++++++++++++++++++++++++++++++++++-------
1 file changed, 108 insertions(+), 22 deletions(-)
diff --git a/drivers/base/dma-contiguous.c b/drivers/base/dma-contiguous.c
index 165c2c299e57..5dfcc3743d9b 100644
--- a/drivers/base/dma-contiguous.c
+++ b/drivers/base/dma-contiguous.c
@@ -182,6 +182,49 @@ static int __init cma_init_reserved_areas(void)
core_initcall(cma_init_reserved_areas);
/**
+ * dma_contiguous_init_reserved_mem() - reserve custom contiguous area
+ * @size: Size of the reserved area (in bytes),
+ * @base: Base address of the reserved area optional, use 0 for any
+ * @limit: End address of the reserved memory (optional, 0 for any).
+ * @res_cma: Pointer to store the created cma region.
+ *
+ * This function reserves memory from early allocator. It should be
+ * called by arch specific code once the early allocator (memblock or bootmem)
+ * has been activated and all other subsystems have already allocated/reserved
+ * memory. This function allows to create custom reserved areas for specific
+ * devices.
+ */
+static int __init dma_contiguous_init_reserved_mem(phys_addr_t size,
+ phys_addr_t base, struct cma **res_cma)
+{
+ struct cma *cma = &cma_areas[cma_area_count];
+ phys_addr_t alignment;
+
+ /* Sanity checks */
+ if (cma_area_count == ARRAY_SIZE(cma_areas)) {
+ pr_err("Not enough slots for CMA reserved regions!\n");
+ return -ENOSPC;
+ }
+
+ if (!size || !memblock_is_region_reserved(base, size))
+ return -EINVAL;
+
+ /* Sanitise input arguments */
+ alignment = PAGE_SIZE << max(MAX_ORDER - 1, pageblock_order);
+ if (ALIGN(base, alignment) != base || ALIGN(size, alignment) != size)
+ return -EINVAL;
+
+ cma->base_pfn = PFN_DOWN(base);
+ cma->count = size >> PAGE_SHIFT;
+ *res_cma = cma;
+ cma_area_count++;
+
+ /* Architecture specific contiguous memory fixup. */
+ dma_contiguous_early_fixup(base, size);
+ return 0;
+}
+
+/**
* dma_contiguous_reserve_area() - reserve custom contiguous area
* @size: Size of the reserved area (in bytes),
* @base: Base address of the reserved area optional, use 0 for any
@@ -197,7 +240,6 @@ core_initcall(cma_init_reserved_areas);
int __init dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base,
phys_addr_t limit, struct cma **res_cma)
{
- struct cma *cma = &cma_areas[cma_area_count];
phys_addr_t alignment;
int ret = 0;
@@ -205,12 +247,6 @@ int __init dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base,
(unsigned long)size, (unsigned long)base,
(unsigned long)limit);
- /* Sanity checks */
- if (cma_area_count == ARRAY_SIZE(cma_areas)) {
- pr_err("Not enough slots for CMA reserved regions!\n");
- return -ENOSPC;
- }
-
if (!size)
return -EINVAL;
@@ -241,21 +277,12 @@ int __init dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base,
}
}
- /*
- * Each reserved area must be initialised later, when more kernel
- * subsystems (like slab allocator) are available.
- */
- cma->base_pfn = PFN_DOWN(base);
- cma->count = size >> PAGE_SHIFT;
- *res_cma = cma;
- cma_area_count++;
-
- pr_info("CMA: reserved %ld MiB at %08lx\n", (unsigned long)size / SZ_1M,
- (unsigned long)base);
-
- /* Architecture specific contiguous memory fixup. */
- dma_contiguous_early_fixup(base, size);
- return 0;
+ ret = dma_contiguous_init_reserved_mem(size, base, res_cma);
+ if (ret == 0) {
+ pr_info("CMA: reserved %ld MiB at %08lx\n",
+ (unsigned long)size / SZ_1M, (unsigned long)base);
+ return 0;
+ }
err:
pr_err("CMA: failed to reserve %ld MiB\n", (unsigned long)size / SZ_1M);
return ret;
@@ -357,3 +384,62 @@ bool dma_release_from_contiguous(struct device *dev, struct page *pages,
return true;
}
+
+/*
+ * Support for reserved memory regions defined in device tree
+ */
+#ifdef CONFIG_OF_RESERVED_MEM
+#include <linux/of.h>
+#include <linux/of_fdt.h>
+#include <linux/of_reserved_mem.h>
+
+#undef pr_fmt
+#define pr_fmt(fmt) fmt
+
+static void rmem_cma_device_init(struct reserved_mem *rmem,
+ struct device *dev, struct of_phandle_args *args)
+{
+ struct cma *cma = rmem->priv;
+ dev_set_cma_area(dev, cma);
+}
+
+static const struct reserved_mem_ops rmem_cma_ops = {
+ .device_init = rmem_cma_device_init,
+};
+
+static int __init rmem_cma_setup(struct reserved_mem *rmem,
+ unsigned long node,
+ const char *uname)
+{
+ phys_addr_t align = PAGE_SIZE << max(MAX_ORDER - 1, pageblock_order);
+ phys_addr_t mask = align - 1;
+ struct cma *cma;
+ int err;
+
+ if (!of_get_flat_dt_prop(node, "reusable", NULL))
+ return -EINVAL;
+
+ if ((rmem->base & mask) || (rmem->size & mask)) {
+ pr_err("Reserved memory: incorrect alignment of CMA region\n");
+ return -EINVAL;
+ }
+
+ err = dma_contiguous_init_reserved_mem(rmem->size, rmem->base, &cma);
+ if (err) {
+ pr_err("Reserved memory: unable to setup CMA region\n");
+ return err;
+ }
+
+ if (of_get_flat_dt_prop(node, "linux,cma-default", NULL))
+ dma_contiguous_set_default(cma);
+
+ rmem->ops = &rmem_cma_ops;
+ rmem->priv = cma;
+
+ pr_info("Reserved memory: created CMA memory pool at %pa, size %ld MiB\n",
+ &rmem->base, (unsigned long)rmem->size / SZ_1M);
+
+ return 0;
+}
+RESERVEDMEM_OF_DECLARE(cma, "shared-dma-pool", rmem_cma_setup);
+#endif
--
1.7.9.5
^ permalink raw reply related
* [PATCH v5 07/11] drivers: dma-coherent: add initialization from device tree
From: Marek Szyprowski @ 2014-02-21 12:25 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel, linaro-mm-sig, devicetree,
linux-doc
Cc: Marek Szyprowski, Benjamin Herrenschmidt, Arnd Bergmann,
Michal Nazarewicz, Grant Likely, Tomasz Figa, Sascha Hauer,
Laura Abbott, Rob Herring, Olof Johansson, Pawel Moll,
Mark Rutland, Stephen Warren, Ian Campbell, Tomasz Figa,
Kumar Gala, Nishanth Peethambaran, Marc, Josh Cartwright,
Catalin Marinas, Will Deacon, Paul Mackerras
In-Reply-To: <1392985527-6260-1-git-send-email-m.szyprowski@samsung.com>
Add support for handling 'shared-dma-pool' reserved-memory device tree
nodes.
Based on previous code provided by Josh Cartwright <joshc@codeaurora.org>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
drivers/base/dma-coherent.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c
index bc256b641027..2343ba5d6d43 100644
--- a/drivers/base/dma-coherent.c
+++ b/drivers/base/dma-coherent.c
@@ -218,3 +218,44 @@ int dma_mmap_from_coherent(struct device *dev, struct vm_area_struct *vma,
return 0;
}
EXPORT_SYMBOL(dma_mmap_from_coherent);
+
+/*
+ * Support for reserved memory regions defined in device tree
+ */
+#ifdef CONFIG_OF_RESERVED_MEM
+#include <linux/of.h>
+#include <linux/of_fdt.h>
+#include <linux/of_reserved_mem.h>
+
+static void rmem_dma_device_init(struct reserved_mem *rmem,
+ struct device *dev, struct of_phandle_args *args)
+{
+ dma_declare_coherent_memory(dev, rmem->base, rmem->base,
+ rmem->size, DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE);
+}
+
+static void rmem_dma_device_release(struct reserved_mem *rmem,
+ struct device *dev)
+{
+ dma_release_declared_memory(dev);
+}
+
+static const struct reserved_mem_ops rmem_dma_ops = {
+ .device_init = rmem_dma_device_init,
+ .device_release = rmem_dma_device_release,
+};
+
+static int __init rmem_dma_setup(struct reserved_mem *rmem,
+ unsigned long node,
+ const char *uname)
+{
+ if (of_get_flat_dt_prop(node, "reusable", NULL))
+ return -EINVAL;
+
+ rmem->ops = &rmem_dma_ops;
+ pr_info("Reserved memory: created DMA memory pool at %pa, size %ld MiB\n",
+ &rmem->base, (unsigned long)rmem->size / SZ_1M);
+ return 0;
+}
+RESERVEDMEM_OF_DECLARE(dma, "shared-dma-pool", rmem_dma_setup);
+#endif
--
1.7.9.5
^ permalink raw reply related
* [PATCH v5 06/11] drivers: of: initialize and assign reserved memory to newly created devices
From: Marek Szyprowski @ 2014-02-21 12:25 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel, linaro-mm-sig, devicetree,
linux-doc
Cc: Marek Szyprowski, Benjamin Herrenschmidt, Arnd Bergmann,
Michal Nazarewicz, Grant Likely, Tomasz Figa, Sascha Hauer,
Laura Abbott, Rob Herring, Olof Johansson, Pawel Moll,
Mark Rutland, Stephen Warren, Ian Campbell, Tomasz Figa,
Kumar Gala, Nishanth Peethambaran, Marc, Josh Cartwright,
Catalin Marinas, Will Deacon, Paul Mackerras
In-Reply-To: <1392985527-6260-1-git-send-email-m.szyprowski@samsung.com>
Use recently introduced of_reserved_mem_device_init() function to
automatically assign respective reserved memory region to the newly created
platform and amba device.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
drivers/of/platform.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 404d1daebefa..3df0b1826e8b 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -21,6 +21,7 @@
#include <linux/of_device.h>
#include <linux/of_irq.h>
#include <linux/of_platform.h>
+#include <linux/of_reserved_mem.h>
#include <linux/platform_device.h>
const struct of_device_id of_default_bus_match_table[] = {
@@ -220,6 +221,8 @@ static struct platform_device *of_platform_device_create_pdata(
dev->dev.bus = &platform_bus_type;
dev->dev.platform_data = platform_data;
+ of_reserved_mem_device_init(&dev->dev);
+
/* We do not fill the DMA ops for platform devices by default.
* This is currently the responsibility of the platform code
* to do such, possibly using a device notifier
@@ -227,6 +230,7 @@ static struct platform_device *of_platform_device_create_pdata(
if (of_device_add(dev) != 0) {
platform_device_put(dev);
+ of_reserved_mem_device_release(&dev->dev);
return NULL;
}
@@ -282,6 +286,8 @@ static struct amba_device *of_amba_device_create(struct device_node *node,
else
of_device_make_bus_id(&dev->dev);
+ of_reserved_mem_device_init(&dev->dev);
+
/* Allow the HW Peripheral ID to be overridden */
prop = of_get_property(node, "arm,primecell-periphid", NULL);
if (prop)
@@ -308,6 +314,7 @@ static struct amba_device *of_amba_device_create(struct device_node *node,
return dev;
err_free:
+ of_reserved_mem_device_release(&dev->dev);
amba_device_put(dev);
return NULL;
}
--
1.7.9.5
^ permalink raw reply related
* [PATCH v5 05/11] drivers: of: add automated assignment of reserved regions to client devices
From: Marek Szyprowski @ 2014-02-21 12:25 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel, linaro-mm-sig, devicetree,
linux-doc
Cc: Marek Szyprowski, Benjamin Herrenschmidt, Arnd Bergmann,
Michal Nazarewicz, Grant Likely, Tomasz Figa, Sascha Hauer,
Laura Abbott, Rob Herring, Olof Johansson, Pawel Moll,
Mark Rutland, Stephen Warren, Ian Campbell, Tomasz Figa,
Kumar Gala, Nishanth Peethambaran, Marc, Josh Cartwright,
Catalin Marinas, Will Deacon, Paul Mackerras
In-Reply-To: <1392985527-6260-1-git-send-email-m.szyprowski@samsung.com>
This patch adds code for automated assignment of reserved memory regions
to struct device. reserved_mem->ops->device_init()/device_cleanup()
callbacks are called to perform reserved memory driver specific
initialization and cleanup. The code looks for 'memory-region' property
in the client device node and assigns region pointed by the found
phandle.
Based on previous code provided by Josh Cartwright <joshc@codeaurora.org>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
drivers/of/of_reserved_mem.c | 74 +++++++++++++++++++++++++++++++++++++++
include/linux/of_reserved_mem.h | 7 ++++
2 files changed, 81 insertions(+)
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 97de6f882f85..b02a7f0a54c8 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -206,8 +206,16 @@ void __init fdt_init_reserved_mem(void)
for (i = 0; i < reserved_mem_count; i++) {
struct reserved_mem *rmem = &reserved_mem[i];
unsigned long node = rmem->fdt_node;
+ unsigned long len;
+ __be32 *prop;
int err = 0;
+ prop = of_get_flat_dt_prop(node, "phandle", &len);
+ if (!prop)
+ prop = of_get_flat_dt_prop(node, "linux,phandle", &len);
+ if (prop)
+ rmem->phandle = of_read_number(prop, len/4);
+
if (rmem->size == 0)
err = __reserved_mem_alloc_size(node, rmem->name,
&rmem->base, &rmem->size);
@@ -215,3 +223,69 @@ void __init fdt_init_reserved_mem(void)
__reserved_mem_init_node(rmem);
}
}
+
+static inline struct reserved_mem *__find_rmem(struct device_node *node)
+{
+ unsigned int i;
+
+ if (!node->phandle)
+ return NULL;
+
+ for (i = 0; i < reserved_mem_count; i++)
+ if (reserved_mem[i].phandle == node->phandle)
+ return &reserved_mem[i];
+ return NULL;
+}
+
+/**
+ * of_reserved_mem_device_init() - assign reserved memory region to given device
+ *
+ * This function assign memory region pointed by "memory-region" device tree
+ * property to the given device.
+ */
+void of_reserved_mem_device_init(struct device *dev)
+{
+ struct device_node *np = dev->of_node;
+ struct reserved_mem *rmem;
+ struct of_phandle_args s;
+ unsigned int i;
+
+ for (i = 0; of_parse_phandle_with_args(np, "memory-region",
+ "#memory-region-cells", i, &s) == 0; i++) {
+
+ rmem = __find_rmem(s.np);
+ if (!rmem || !rmem->ops || !rmem->ops->device_init) {
+ of_node_put(s.np);
+ continue;
+ }
+
+ rmem->ops->device_init(rmem, dev, &s);
+ dev_info(dev, "assigned reserved memory node %s\n", rmem->name);
+ of_node_put(s.np);
+ break;
+ }
+}
+
+/**
+ * of_reserved_mem_device_release() - release reserved memory device structures
+ *
+ * This function releases structures allocated for memory region handling for
+ * the given device.
+ */
+void of_reserved_mem_device_release(struct device *dev)
+{
+ struct device_node *np = dev->of_node;
+ struct reserved_mem *rmem;
+ struct of_phandle_args s;
+ unsigned int i;
+
+ for (i = 0; of_parse_phandle_with_args(np, "memory-region",
+ "#memory-region-cells", i, &s) == 0; i++) {
+
+ rmem = __find_rmem(s.np);
+ if (rmem && rmem->ops && rmem->ops->device_release)
+ rmem->ops->device_release(rmem, dev);
+
+ of_node_put(s.np);
+ }
+}
diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h
index f707176619a3..a2a25de297de 100644
--- a/include/linux/of_reserved_mem.h
+++ b/include/linux/of_reserved_mem.h
@@ -8,6 +8,7 @@ struct reserved_mem_ops;
struct reserved_mem {
const char *name;
unsigned long fdt_node;
+ unsigned long phandle;
const struct reserved_mem_ops *ops;
phys_addr_t base;
phys_addr_t size;
@@ -26,6 +27,9 @@ typedef int (*reservedmem_of_init_fn)(struct reserved_mem *rmem,
unsigned long node, const char *uname);
#ifdef CONFIG_OF_RESERVED_MEM
+void of_reserved_mem_device_init(struct device *dev);
+void of_reserved_mem_device_release(struct device *dev);
+
void fdt_init_reserved_mem(void);
void fdt_reserved_mem_save_node(unsigned long node, const char *uname,
phys_addr_t base, phys_addr_t size);
@@ -38,6 +42,9 @@ void fdt_reserved_mem_save_node(unsigned long node, const char *uname,
init : init }
#else
+static inline void of_reserved_mem_device_init(struct device *dev) { }
+static inline void of_reserved_mem_device_release(struct device *pdev) { }
+
static inline void fdt_init_reserved_mem(void) { }
static inline void fdt_reserved_mem_save_node(unsigned long node,
const char *uname, phys_addr_t base, phys_addr_t size) { }
--
1.7.9.5
^ permalink raw reply related
* [PATCH v5 04/11] drivers: of: add support for custom reserved memory drivers
From: Marek Szyprowski @ 2014-02-21 12:25 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel, linaro-mm-sig, devicetree,
linux-doc
Cc: Marek Szyprowski, Benjamin Herrenschmidt, Arnd Bergmann,
Michal Nazarewicz, Grant Likely, Tomasz Figa, Sascha Hauer,
Laura Abbott, Rob Herring, Olof Johansson, Pawel Moll,
Mark Rutland, Stephen Warren, Ian Campbell, Tomasz Figa,
Kumar Gala, Nishanth Peethambaran, Marc, Josh Cartwright,
Catalin Marinas, Will Deacon, Paul Mackerras
In-Reply-To: <1392985527-6260-1-git-send-email-m.szyprowski@samsung.com>
Add support for custom reserved memory drivers. Call their init() function
for each reserved region and prepare for using operations provided by them
with by the reserved_mem->ops array.
Based on previous code provided by Josh Cartwright <joshc@codeaurora.org>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
drivers/of/of_reserved_mem.c | 29 +++++++++++++++++++++++++++++
include/asm-generic/vmlinux.lds.h | 11 +++++++++++
include/linux/of_reserved_mem.h | 33 +++++++++++++++++++++++++++++++++
3 files changed, 73 insertions(+)
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index c7ca6a4a42d1..97de6f882f85 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -170,6 +170,33 @@ static int __init __reserved_mem_alloc_size(unsigned long node,
return 0;
}
+static const struct of_device_id __rmem_of_table_sentinel
+ __used __section(__reservedmem_of_table_end);
+
+/**
+ * res_mem_init_node() - call region specific reserved memory init code
+ */
+static int __init __reserved_mem_init_node(struct reserved_mem *rmem)
+{
+ extern const struct of_device_id __reservedmem_of_table[];
+ const struct of_device_id *i;
+
+ for (i = __reservedmem_of_table; i < &__rmem_of_table_sentinel; i++) {
+ reservedmem_of_init_fn initfn = i->data;
+ const char *compat = i->compatible;
+
+ if (!of_flat_dt_is_compatible(rmem->fdt_node, compat))
+ continue;
+
+ if (initfn(rmem, rmem->fdt_node, rmem->name) == 0) {
+ pr_info("Reserved memory: initialized node %s, compatible id %s\n",
+ rmem->name, compat);
+ return 0;
+ }
+ }
+ return -ENOENT;
+}
+
/**
* fdt_init_reserved_mem - allocate and init all saved reserved memory regions
*/
@@ -184,5 +211,7 @@ void __init fdt_init_reserved_mem(void)
if (rmem->size == 0)
err = __reserved_mem_alloc_size(node, rmem->name,
&rmem->base, &rmem->size);
+ if (err == 0)
+ __reserved_mem_init_node(rmem);
}
}
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index bc2121fa9132..f10f64fcc815 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -167,6 +167,16 @@
#define CLK_OF_TABLES()
#endif
+#ifdef CONFIG_OF_RESERVED_MEM
+#define RESERVEDMEM_OF_TABLES() \
+ . = ALIGN(8); \
+ VMLINUX_SYMBOL(__reservedmem_of_table) = .; \
+ *(__reservedmem_of_table) \
+ *(__reservedmem_of_table_end)
+#else
+#define RESERVEDMEM_OF_TABLES()
+#endif
+
#define KERNEL_DTB() \
STRUCT_ALIGN(); \
VMLINUX_SYMBOL(__dtb_start) = .; \
@@ -490,6 +500,7 @@
TRACE_SYSCALLS() \
MEM_DISCARD(init.rodata) \
CLK_OF_TABLES() \
+ RESERVEDMEM_OF_TABLES() \
CLKSRC_OF_TABLES() \
KERNEL_DTB() \
IRQCHIP_OF_MATCH_TABLE()
diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h
index 89226ed7d954..f707176619a3 100644
--- a/include/linux/of_reserved_mem.h
+++ b/include/linux/of_reserved_mem.h
@@ -1,21 +1,54 @@
#ifndef __OF_RESERVED_MEM_H
#define __OF_RESERVED_MEM_H
+struct device;
+struct of_phandle_args;
+struct reserved_mem_ops;
+
struct reserved_mem {
const char *name;
unsigned long fdt_node;
+ const struct reserved_mem_ops *ops;
phys_addr_t base;
phys_addr_t size;
+ void *priv;
+};
+
+struct reserved_mem_ops {
+ void (*device_init)(struct reserved_mem *rmem,
+ struct device *dev,
+ struct of_phandle_args *args);
+ void (*device_release)(struct reserved_mem *rmem,
+ struct device *dev);
};
+typedef int (*reservedmem_of_init_fn)(struct reserved_mem *rmem,
+ unsigned long node, const char *uname);
+
#ifdef CONFIG_OF_RESERVED_MEM
void fdt_init_reserved_mem(void);
void fdt_reserved_mem_save_node(unsigned long node, const char *uname,
phys_addr_t base, phys_addr_t size);
+
+#define RESERVEDMEM_OF_DECLARE(name, compat, init) \
+ static const struct of_device_id __reservedmem_of_table_##name \
+ __used __section(__reservedmem_of_table) \
+ = { .compatible = compat, \
+ .data = (init == (reservedmem_of_init_fn)NULL) ? \
+ init : init }
+
#else
static inline void fdt_init_reserved_mem(void) { }
static inline void fdt_reserved_mem_save_node(unsigned long node,
const char *uname, phys_addr_t base, phys_addr_t size) { }
+
+#define RESERVEDMEM_OF_DECLARE(name, compat, init) \
+ static const struct of_device_id __reservedmem_of_table_##name \
+ __attribute__((unused)) \
+ = { .compatible = compat, \
+ .data = (init == (reservedmem_of_init_fn)NULL) ? \
+ init : init }
+
#endif
#endif /* __OF_RESERVED_MEM_H */
--
1.7.9.5
^ permalink raw reply related
* [PATCH v5 03/11] drivers: of: add initialization code for dynamic reserved memory
From: Marek Szyprowski @ 2014-02-21 12:25 UTC (permalink / raw)
To: linux-kernel, linux-arm-kernel, linaro-mm-sig, devicetree,
linux-doc
Cc: Marek Szyprowski, Benjamin Herrenschmidt, Arnd Bergmann,
Michal Nazarewicz, Grant Likely, Tomasz Figa, Sascha Hauer,
Laura Abbott, Rob Herring, Olof Johansson, Pawel Moll,
Mark Rutland, Stephen Warren, Ian Campbell, Tomasz Figa,
Kumar Gala, Nishanth Peethambaran, Marc, Josh Cartwright,
Catalin Marinas, Will Deacon, Paul Mackerras
In-Reply-To: <1392985527-6260-1-git-send-email-m.szyprowski@samsung.com>
This patch adds support for dynamically allocated reserved memory regions
declared in device tree. Such regions are defined by 'size', 'alignment'
and 'alloc-ranges' properties.
Based on previous code provided by Josh Cartwright <joshc@codeaurora.org>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
drivers/of/Kconfig | 6 ++
drivers/of/Makefile | 1 +
drivers/of/fdt.c | 13 ++-
drivers/of/of_reserved_mem.c | 188 +++++++++++++++++++++++++++++++++++++++
include/linux/of_reserved_mem.h | 21 +++++
5 files changed, 227 insertions(+), 2 deletions(-)
create mode 100644 drivers/of/of_reserved_mem.c
create mode 100644 include/linux/of_reserved_mem.h
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index c6973f101a3e..30a7d87a8077 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -75,4 +75,10 @@ config OF_MTD
depends on MTD
def_bool y
+config OF_RESERVED_MEM
+ depends on OF_EARLY_FLATTREE
+ bool
+ help
+ Helpers to allow for reservation of memory regions
+
endmenu # OF
diff --git a/drivers/of/Makefile b/drivers/of/Makefile
index efd05102c405..ed9660adad77 100644
--- a/drivers/of/Makefile
+++ b/drivers/of/Makefile
@@ -9,3 +9,4 @@ obj-$(CONFIG_OF_MDIO) += of_mdio.o
obj-$(CONFIG_OF_PCI) += of_pci.o
obj-$(CONFIG_OF_PCI_IRQ) += of_pci_irq.o
obj-$(CONFIG_OF_MTD) += of_mtd.o
+obj-$(CONFIG_OF_RESERVED_MEM) += of_reserved_mem.o
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 12809e20ef71..eafe5805257a 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -15,6 +15,7 @@
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_fdt.h>
+#include <linux/of_reserved_mem.h>
#include <linux/string.h>
#include <linux/errno.h>
#include <linux/slab.h>
@@ -449,7 +450,7 @@ static int __init __reserved_mem_reserve_reg(unsigned long node,
phys_addr_t base, size;
unsigned long len;
__be32 *prop;
- int nomap;
+ int nomap, first = 1;
prop = of_get_flat_dt_prop(node, "reg", &len);
if (!prop)
@@ -476,6 +477,10 @@ static int __init __reserved_mem_reserve_reg(unsigned long node,
uname, &base, (unsigned long)size / SZ_1M);
len -= t_len;
+ if (first) {
+ fdt_reserved_mem_save_node(node, uname, base, size);
+ first = 0;
+ }
}
return 0;
}
@@ -506,6 +511,7 @@ static int __init __fdt_scan_reserved_mem(unsigned long node, const char *uname,
{
static int found;
const char *status;
+ int err;
if (!found && depth == 1 && strcmp(uname, "reserved-memory") == 0) {
if (__reserved_mem_check_root(node) != 0) {
@@ -528,7 +534,9 @@ static int __init __fdt_scan_reserved_mem(unsigned long node, const char *uname,
if (status && strcmp(status, "okay") != 0 && strcmp(status, "ok") != 0)
return 0;
- __reserved_mem_reserve_reg(node, uname);
+ err = __reserved_mem_reserve_reg(node, uname);
+ if (err == -ENOENT && of_get_flat_dt_prop(node, "size", NULL))
+ fdt_reserved_mem_save_node(node, uname, 0, 0);
/* scan next node */
return 0;
@@ -544,6 +552,7 @@ static int __init __fdt_scan_reserved_mem(unsigned long node, const char *uname,
void __init early_init_fdt_scan_reserved_mem(void)
{
of_scan_flat_dt(__fdt_scan_reserved_mem, NULL);
+ fdt_init_reserved_mem();
}
/**
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
new file mode 100644
index 000000000000..c7ca6a4a42d1
--- /dev/null
+++ b/drivers/of/of_reserved_mem.c
@@ -0,0 +1,188 @@
+/*
+ * Device tree based initialization code for reserved memory.
+ *
+ * Copyright (c) 2013, The Linux Foundation. All Rights Reserved.
+ * Copyright (c) 2013,2014 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ * Author: Marek Szyprowski <m.szyprowski@samsung.com>
+ * Author: Josh Cartwright <joshc@codeaurora.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License or (at your optional) any later version of the license.
+ */
+
+#include <linux/err.h>
+#include <linux/of.h>
+#include <linux/of_fdt.h>
+#include <linux/of_platform.h>
+#include <linux/mm.h>
+#include <linux/sizes.h>
+#include <linux/of_reserved_mem.h>
+
+#define MAX_RESERVED_REGIONS 16
+static struct reserved_mem reserved_mem[MAX_RESERVED_REGIONS];
+static int reserved_mem_count;
+
+#if defined(CONFIG_HAVE_MEMBLOCK)
+#include <linux/memblock.h>
+int __init __weak early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
+ phys_addr_t align, phys_addr_t start, phys_addr_t end, bool nomap,
+ phys_addr_t *res_base)
+{
+ /*
+ * We use __memblock_alloc_base() because memblock_alloc_base()
+ * panic()s on allocation failure.
+ */
+ phys_addr_t base = __memblock_alloc_base(size, align, end);
+ if (!base)
+ return -ENOMEM;
+
+ /*
+ * Check if the allocated region fits in to start..end window
+ */
+ if (base < start) {
+ memblock_free(base, size);
+ return -ENOMEM;
+ }
+
+ *res_base = base;
+ if (nomap)
+ return memblock_remove(base, size);
+ return 0;
+}
+#else
+int __init __weak early_init_dt_alloc_reserved_memory_arch(phys_addr_t size,
+ phys_addr_t align, phys_addr_t start, phys_addr_t end, bool nomap,
+ phys_addr_t *res_base)
+{
+ pr_error("Reserved memory not supported, ignoring region 0x%llx%s\n",
+ size, nomap ? " (nomap)" : "");
+ return -ENOSYS;
+}
+#endif
+
+/**
+ * res_mem_save_node() - save fdt node for second pass initialization
+ */
+void __init fdt_reserved_mem_save_node(unsigned long node, const char *uname,
+ phys_addr_t base, phys_addr_t size)
+{
+ struct reserved_mem *rmem = &reserved_mem[reserved_mem_count];
+
+ if (reserved_mem_count == ARRAY_SIZE(reserved_mem)) {
+ pr_err("Reserved memory: not enough space all defined regions.\n");
+ return;
+ }
+
+ rmem->fdt_node = node;
+ rmem->name = uname;
+ rmem->base = base;
+ rmem->size = size;
+
+ reserved_mem_count++;
+ return;
+}
+
+/**
+ * res_mem_alloc_size() - allocate reserved memory described by 'size', 'align'
+ * and 'alloc-ranges' properties
+ */
+static int __init __reserved_mem_alloc_size(unsigned long node,
+ const char *uname, phys_addr_t *res_base, phys_addr_t *res_size)
+{
+ int t_len = (dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32);
+ phys_addr_t start = 0, end = 0;
+ phys_addr_t base = 0, align = 0, size;
+ unsigned long len;
+ __be32 *prop;
+ int nomap;
+ int ret;
+
+ prop = of_get_flat_dt_prop(node, "size", &len);
+ if (!prop)
+ return -EINVAL;
+
+ if (len != dt_root_size_cells * sizeof(__be32)) {
+ pr_err("Reserved memory: invalid size property in '%s' node.\n",
+ uname);
+ return -EINVAL;
+ }
+ size = dt_mem_next_cell(dt_root_size_cells, &prop);
+
+ nomap = of_get_flat_dt_prop(node, "no-map", NULL) != NULL;
+
+ prop = of_get_flat_dt_prop(node, "alignment", &len);
+ if (prop) {
+ if (len != dt_root_addr_cells * sizeof(__be32)) {
+ pr_err("Reserved memory: invalid alignment property in '%s' node.\n",
+ uname);
+ return -EINVAL;
+ }
+ align = dt_mem_next_cell(dt_root_addr_cells, &prop);
+ }
+
+ prop = of_get_flat_dt_prop(node, "alloc-ranges", &len);
+ if (prop) {
+
+ if (len % t_len != 0) {
+ pr_err("Reserved memory: invalid alloc-ranges property in '%s', skipping node.\n",
+ uname);
+ return -EINVAL;
+ }
+
+ base = 0;
+
+ while (len > 0) {
+ start = dt_mem_next_cell(dt_root_addr_cells, &prop);
+ end = start + dt_mem_next_cell(dt_root_size_cells,
+ &prop);
+
+ ret = early_init_dt_alloc_reserved_memory_arch(size,
+ align, start, end, nomap, &base);
+ if (ret == 0) {
+ pr_debug("Reserved memory: allocated memory for '%s' node: base %pa, size %ld MiB\n",
+ uname, &base,
+ (unsigned long)size / SZ_1M);
+ break;
+ }
+ len -= t_len;
+ }
+
+ } else {
+ ret = early_init_dt_alloc_reserved_memory_arch(size, align,
+ 0, 0, nomap, &base);
+ if (ret == 0)
+ pr_debug("Reserved memory: allocated memory for '%s' node: base %pa, size %ld MiB\n",
+ uname, &base, (unsigned long)size / SZ_1M);
+ }
+
+ if (base == 0) {
+ pr_info("Reserved memory: failed to allocate memory for node '%s'\n",
+ uname);
+ return -ENOMEM;
+ }
+
+ *res_base = base;
+ *res_size = size;
+
+ return 0;
+}
+
+/**
+ * fdt_init_reserved_mem - allocate and init all saved reserved memory regions
+ */
+void __init fdt_init_reserved_mem(void)
+{
+ int i;
+ for (i = 0; i < reserved_mem_count; i++) {
+ struct reserved_mem *rmem = &reserved_mem[i];
+ unsigned long node = rmem->fdt_node;
+ int err = 0;
+
+ if (rmem->size == 0)
+ err = __reserved_mem_alloc_size(node, rmem->name,
+ &rmem->base, &rmem->size);
+ }
+}
diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h
new file mode 100644
index 000000000000..89226ed7d954
--- /dev/null
+++ b/include/linux/of_reserved_mem.h
@@ -0,0 +1,21 @@
+#ifndef __OF_RESERVED_MEM_H
+#define __OF_RESERVED_MEM_H
+
+struct reserved_mem {
+ const char *name;
+ unsigned long fdt_node;
+ phys_addr_t base;
+ phys_addr_t size;
+};
+
+#ifdef CONFIG_OF_RESERVED_MEM
+void fdt_init_reserved_mem(void);
+void fdt_reserved_mem_save_node(unsigned long node, const char *uname,
+ phys_addr_t base, phys_addr_t size);
+#else
+static inline void fdt_init_reserved_mem(void) { }
+static inline void fdt_reserved_mem_save_node(unsigned long node,
+ const char *uname, phys_addr_t base, phys_addr_t size) { }
+#endif
+
+#endif /* __OF_RESERVED_MEM_H */
--
1.7.9.5
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox