Re: [U-Boot] [PATCH 2/4] soc: qualcomm: Add Shared Memory Manager driver

2018-06-13 Thread Ramon Fried
On June 9, 2018 2:17:45 PM GMT+03:00, Heinrich Schuchardt  
wrote:
>On 06/09/2018 12:29 PM, Ramon Fried wrote:
>> On Sat, Jun 9, 2018 at 1:12 PM, Heinrich Schuchardt
> wrote:
>>> On 06/09/2018 01:06 PM, Ramon Fried wrote:
 The Shared Memory Manager driver implements an interface for
>allocating
 and accessing items in the memory area shared among all of the
 processors in a Qualcomm platform.

 Adapted from the Linux driver (4.17)
>>>
>>> Please, run scripts/checkpatch on this patch an fix all errors and
>>> warnings, e.g.
>> Hi Heinrich,
>> Actually I did run it, and I also run it in Linux and got the same
>results.
>> I thought it will be better to keep the driver aligned to Linux than
>> to fix these warnings.
>> But if can surely fix it, what do you suggest ?
>
>At least add a comment in the commit message why you diverge from our
>coding standard.
>
I just sent checkpatch fixes to the Linux kernel list. Hopefully it will be 
accepted. 
BTW. I'm replacing Mateusz as the maintainer for arch-snapdragon,
Thanks, Ramon 
>As Mateusz will be the maintainer he should decide.
>
>Best regards
>
>Heinrich


-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/4] soc: qualcomm: Add Shared Memory Manager driver

2018-06-13 Thread Ramon Fried
On June 13, 2018 4:29:03 AM GMT+03:00, Simon Glass  wrote:
>Hi Ramon,
>
>On 12 June 2018 at 02:50, Ramon Fried  wrote:
>> On June 11, 2018 10:38:45 PM GMT+03:00, Simon Glass
> wrote:
>>>Hi Ramon,
>>>
>>>On 11 June 2018 at 13:14, Ramon Fried  wrote:


 On Mon, Jun 11, 2018 at 5:53 PM, Simon Glass 
>>>wrote:
>
> Hi Ramon,
>
> On 9 June 2018 at 03:06, Ramon Fried 
>wrote:
> > The Shared Memory Manager driver implements an interface for
>>>allocating
> > and accessing items in the memory area shared among all of the
> > processors in a Qualcomm platform.
> >
> > Adapted from the Linux driver (4.17)
> >
> > Changes from the original Linux driver:
> > * Removed HW spinlock mechanism, which is irrelevant
> > in U-boot particualar use case, which is just reading from the
>>>smem.
> > * adaptaion from Linux driver model to U-boot's.
> >
> > Cc: Bjorn Andersson 
> > Signed-off-by: Ramon Fried 
> > ---
> >
> >  MAINTAINERS   |   1 +
> >  arch/arm/Kconfig  |   1 +
> >  drivers/Kconfig   |   2 +
> >  drivers/soc/Kconfig   |   5 +
> >  drivers/soc/Makefile  |   1 +
> >  drivers/soc/qualcomm/Kconfig  |  11 +
> >  drivers/soc/qualcomm/Makefile |   3 +
> >  drivers/soc/qualcomm/smem.c   | 934
>>>++
> >  8 files changed, 958 insertions(+)
> >  create mode 100644 drivers/soc/Kconfig
> >  create mode 100644 drivers/soc/qualcomm/Kconfig
> >  create mode 100644 drivers/soc/qualcomm/Makefile
> >  create mode 100644 drivers/soc/qualcomm/smem.c
>
> Sorry, but NAK on this.
>
> This patch supports direct calls into a driver which is not
>allowed.
> This should be done through the driver's uclass API, not through
> direct calls.
>
 Hi Simon,
 I see your point.
 As you probably see, I was looking at the DM framework for the
>>>convenience
 it
 gives with binding device-tree nodes and drivers.
 If it's not an option I'll rewrite it as as arch-code under
>>>mach-snapdragon.
 Thanks,
 Ramon.
>>>
>>>You are correct that you should be using driver model. It's that you
>>>need to do it fully, with a proper API. There are lots of examples.
>>>
>> Doesn't it make sense to add some facility  for drivers that don't
>export common functionalities. Like Linux platform drivers?
>
>Well this is how things used to work in U-Boot before driver model.
>
>Now we are trying to move things to driver model.
>
>It does not look like you have many calls, so it should be easy enough
>to move it to a uclass.
That's what I'll do. 
Thanks. 
>
>You can also add a command to access the device. People can see the
>tree of devices with 'dm tree', etc.
>
>Regards,
>Simon


-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/4] soc: qualcomm: Add Shared Memory Manager driver

2018-06-12 Thread Simon Glass
Hi Ramon,

On 12 June 2018 at 02:50, Ramon Fried  wrote:
> On June 11, 2018 10:38:45 PM GMT+03:00, Simon Glass  wrote:
>>Hi Ramon,
>>
>>On 11 June 2018 at 13:14, Ramon Fried  wrote:
>>>
>>>
>>> On Mon, Jun 11, 2018 at 5:53 PM, Simon Glass 
>>wrote:

 Hi Ramon,

 On 9 June 2018 at 03:06, Ramon Fried  wrote:
 > The Shared Memory Manager driver implements an interface for
>>allocating
 > and accessing items in the memory area shared among all of the
 > processors in a Qualcomm platform.
 >
 > Adapted from the Linux driver (4.17)
 >
 > Changes from the original Linux driver:
 > * Removed HW spinlock mechanism, which is irrelevant
 > in U-boot particualar use case, which is just reading from the
>>smem.
 > * adaptaion from Linux driver model to U-boot's.
 >
 > Cc: Bjorn Andersson 
 > Signed-off-by: Ramon Fried 
 > ---
 >
 >  MAINTAINERS   |   1 +
 >  arch/arm/Kconfig  |   1 +
 >  drivers/Kconfig   |   2 +
 >  drivers/soc/Kconfig   |   5 +
 >  drivers/soc/Makefile  |   1 +
 >  drivers/soc/qualcomm/Kconfig  |  11 +
 >  drivers/soc/qualcomm/Makefile |   3 +
 >  drivers/soc/qualcomm/smem.c   | 934
>>++
 >  8 files changed, 958 insertions(+)
 >  create mode 100644 drivers/soc/Kconfig
 >  create mode 100644 drivers/soc/qualcomm/Kconfig
 >  create mode 100644 drivers/soc/qualcomm/Makefile
 >  create mode 100644 drivers/soc/qualcomm/smem.c

 Sorry, but NAK on this.

 This patch supports direct calls into a driver which is not allowed.
 This should be done through the driver's uclass API, not through
 direct calls.

>>> Hi Simon,
>>> I see your point.
>>> As you probably see, I was looking at the DM framework for the
>>convenience
>>> it
>>> gives with binding device-tree nodes and drivers.
>>> If it's not an option I'll rewrite it as as arch-code under
>>mach-snapdragon.
>>> Thanks,
>>> Ramon.
>>
>>You are correct that you should be using driver model. It's that you
>>need to do it fully, with a proper API. There are lots of examples.
>>
> Doesn't it make sense to add some facility  for drivers that don't export 
> common functionalities. Like Linux platform drivers?

Well this is how things used to work in U-Boot before driver model.

Now we are trying to move things to driver model.

It does not look like you have many calls, so it should be easy enough
to move it to a uclass.

You can also add a command to access the device. People can see the
tree of devices with 'dm tree', etc.

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/4] soc: qualcomm: Add Shared Memory Manager driver

2018-06-12 Thread Ramon Fried
On June 11, 2018 10:38:45 PM GMT+03:00, Simon Glass  wrote:
>Hi Ramon,
>
>On 11 June 2018 at 13:14, Ramon Fried  wrote:
>>
>>
>> On Mon, Jun 11, 2018 at 5:53 PM, Simon Glass 
>wrote:
>>>
>>> Hi Ramon,
>>>
>>> On 9 June 2018 at 03:06, Ramon Fried  wrote:
>>> > The Shared Memory Manager driver implements an interface for
>allocating
>>> > and accessing items in the memory area shared among all of the
>>> > processors in a Qualcomm platform.
>>> >
>>> > Adapted from the Linux driver (4.17)
>>> >
>>> > Changes from the original Linux driver:
>>> > * Removed HW spinlock mechanism, which is irrelevant
>>> > in U-boot particualar use case, which is just reading from the
>smem.
>>> > * adaptaion from Linux driver model to U-boot's.
>>> >
>>> > Cc: Bjorn Andersson 
>>> > Signed-off-by: Ramon Fried 
>>> > ---
>>> >
>>> >  MAINTAINERS   |   1 +
>>> >  arch/arm/Kconfig  |   1 +
>>> >  drivers/Kconfig   |   2 +
>>> >  drivers/soc/Kconfig   |   5 +
>>> >  drivers/soc/Makefile  |   1 +
>>> >  drivers/soc/qualcomm/Kconfig  |  11 +
>>> >  drivers/soc/qualcomm/Makefile |   3 +
>>> >  drivers/soc/qualcomm/smem.c   | 934
>++
>>> >  8 files changed, 958 insertions(+)
>>> >  create mode 100644 drivers/soc/Kconfig
>>> >  create mode 100644 drivers/soc/qualcomm/Kconfig
>>> >  create mode 100644 drivers/soc/qualcomm/Makefile
>>> >  create mode 100644 drivers/soc/qualcomm/smem.c
>>>
>>> Sorry, but NAK on this.
>>>
>>> This patch supports direct calls into a driver which is not allowed.
>>> This should be done through the driver's uclass API, not through
>>> direct calls.
>>>
>> Hi Simon,
>> I see your point.
>> As you probably see, I was looking at the DM framework for the
>convenience
>> it
>> gives with binding device-tree nodes and drivers.
>> If it's not an option I'll rewrite it as as arch-code under
>mach-snapdragon.
>> Thanks,
>> Ramon.
>
>You are correct that you should be using driver model. It's that you
>need to do it fully, with a proper API. There are lots of examples.
>
Doesn't it make sense to add some facility  for drivers that don't export 
common functionalities. Like Linux platform drivers? 

>Regards,
>Simon


-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/4] soc: qualcomm: Add Shared Memory Manager driver

2018-06-11 Thread Simon Glass
Hi Ramon,

On 11 June 2018 at 13:14, Ramon Fried  wrote:
>
>
> On Mon, Jun 11, 2018 at 5:53 PM, Simon Glass  wrote:
>>
>> Hi Ramon,
>>
>> On 9 June 2018 at 03:06, Ramon Fried  wrote:
>> > The Shared Memory Manager driver implements an interface for allocating
>> > and accessing items in the memory area shared among all of the
>> > processors in a Qualcomm platform.
>> >
>> > Adapted from the Linux driver (4.17)
>> >
>> > Changes from the original Linux driver:
>> > * Removed HW spinlock mechanism, which is irrelevant
>> > in U-boot particualar use case, which is just reading from the smem.
>> > * adaptaion from Linux driver model to U-boot's.
>> >
>> > Cc: Bjorn Andersson 
>> > Signed-off-by: Ramon Fried 
>> > ---
>> >
>> >  MAINTAINERS   |   1 +
>> >  arch/arm/Kconfig  |   1 +
>> >  drivers/Kconfig   |   2 +
>> >  drivers/soc/Kconfig   |   5 +
>> >  drivers/soc/Makefile  |   1 +
>> >  drivers/soc/qualcomm/Kconfig  |  11 +
>> >  drivers/soc/qualcomm/Makefile |   3 +
>> >  drivers/soc/qualcomm/smem.c   | 934 ++
>> >  8 files changed, 958 insertions(+)
>> >  create mode 100644 drivers/soc/Kconfig
>> >  create mode 100644 drivers/soc/qualcomm/Kconfig
>> >  create mode 100644 drivers/soc/qualcomm/Makefile
>> >  create mode 100644 drivers/soc/qualcomm/smem.c
>>
>> Sorry, but NAK on this.
>>
>> This patch supports direct calls into a driver which is not allowed.
>> This should be done through the driver's uclass API, not through
>> direct calls.
>>
> Hi Simon,
> I see your point.
> As you probably see, I was looking at the DM framework for the convenience
> it
> gives with binding device-tree nodes and drivers.
> If it's not an option I'll rewrite it as as arch-code under mach-snapdragon.
> Thanks,
> Ramon.

You are correct that you should be using driver model. It's that you
need to do it fully, with a proper API. There are lots of examples.

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/4] soc: qualcomm: Add Shared Memory Manager driver

2018-06-11 Thread Ramon Fried
On Mon, Jun 11, 2018 at 5:53 PM, Simon Glass  wrote:

> Hi Ramon,
>
> On 9 June 2018 at 03:06, Ramon Fried  wrote:
> > The Shared Memory Manager driver implements an interface for allocating
> > and accessing items in the memory area shared among all of the
> > processors in a Qualcomm platform.
> >
> > Adapted from the Linux driver (4.17)
> >
> > Changes from the original Linux driver:
> > * Removed HW spinlock mechanism, which is irrelevant
> > in U-boot particualar use case, which is just reading from the smem.
> > * adaptaion from Linux driver model to U-boot's.
> >
> > Cc: Bjorn Andersson 
> > Signed-off-by: Ramon Fried 
> > ---
> >
> >  MAINTAINERS   |   1 +
> >  arch/arm/Kconfig  |   1 +
> >  drivers/Kconfig   |   2 +
> >  drivers/soc/Kconfig   |   5 +
> >  drivers/soc/Makefile  |   1 +
> >  drivers/soc/qualcomm/Kconfig  |  11 +
> >  drivers/soc/qualcomm/Makefile |   3 +
> >  drivers/soc/qualcomm/smem.c   | 934 ++
> >  8 files changed, 958 insertions(+)
> >  create mode 100644 drivers/soc/Kconfig
> >  create mode 100644 drivers/soc/qualcomm/Kconfig
> >  create mode 100644 drivers/soc/qualcomm/Makefile
> >  create mode 100644 drivers/soc/qualcomm/smem.c
>
> Sorry, but NAK on this.
>
> This patch supports direct calls into a driver which is not allowed.
> This should be done through the driver's uclass API, not through
> direct calls.
>
> Hi Simon,
I see your point.
As you probably see, I was looking at the DM framework for the convenience
it
gives with binding device-tree nodes and drivers.
If it's not an option I'll rewrite it as as arch-code under mach-snapdragon.
Thanks,
Ramon.

The new uclass needs a sandbox driver and test, once you decide on that API
>
> Regards,
> Simon
>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/4] soc: qualcomm: Add Shared Memory Manager driver

2018-06-11 Thread Simon Glass
Hi Ramon,

On 9 June 2018 at 03:06, Ramon Fried  wrote:
> The Shared Memory Manager driver implements an interface for allocating
> and accessing items in the memory area shared among all of the
> processors in a Qualcomm platform.
>
> Adapted from the Linux driver (4.17)
>
> Changes from the original Linux driver:
> * Removed HW spinlock mechanism, which is irrelevant
> in U-boot particualar use case, which is just reading from the smem.
> * adaptaion from Linux driver model to U-boot's.
>
> Cc: Bjorn Andersson 
> Signed-off-by: Ramon Fried 
> ---
>
>  MAINTAINERS   |   1 +
>  arch/arm/Kconfig  |   1 +
>  drivers/Kconfig   |   2 +
>  drivers/soc/Kconfig   |   5 +
>  drivers/soc/Makefile  |   1 +
>  drivers/soc/qualcomm/Kconfig  |  11 +
>  drivers/soc/qualcomm/Makefile |   3 +
>  drivers/soc/qualcomm/smem.c   | 934 ++
>  8 files changed, 958 insertions(+)
>  create mode 100644 drivers/soc/Kconfig
>  create mode 100644 drivers/soc/qualcomm/Kconfig
>  create mode 100644 drivers/soc/qualcomm/Makefile
>  create mode 100644 drivers/soc/qualcomm/smem.c

Sorry, but NAK on this.

This patch supports direct calls into a driver which is not allowed.
This should be done through the driver's uclass API, not through
direct calls.

The new uclass needs a sandbox driver and test, once you decide on that API

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/4] soc: qualcomm: Add Shared Memory Manager driver

2018-06-09 Thread Heinrich Schuchardt
On 06/09/2018 12:29 PM, Ramon Fried wrote:
> On Sat, Jun 9, 2018 at 1:12 PM, Heinrich Schuchardt  
> wrote:
>> On 06/09/2018 01:06 PM, Ramon Fried wrote:
>>> The Shared Memory Manager driver implements an interface for allocating
>>> and accessing items in the memory area shared among all of the
>>> processors in a Qualcomm platform.
>>>
>>> Adapted from the Linux driver (4.17)
>>
>> Please, run scripts/checkpatch on this patch an fix all errors and
>> warnings, e.g.
> Hi Heinrich,
> Actually I did run it, and I also run it in Linux and got the same results.
> I thought it will be better to keep the driver aligned to Linux than
> to fix these warnings.
> But if can surely fix it, what do you suggest ?

At least add a comment in the commit message why you diverge from our
coding standard.

As Mateusz will be the maintainer he should decide.

Best regards

Heinrich


___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/4] soc: qualcomm: Add Shared Memory Manager driver

2018-06-09 Thread Ramon Fried
On Sat, Jun 9, 2018 at 1:24 PM, Heinrich Schuchardt  wrote:
> On 06/09/2018 01:06 PM, Ramon Fried wrote:
>> The Shared Memory Manager driver implements an interface for allocating
>> and accessing items in the memory area shared among all of the
>> processors in a Qualcomm platform.
>>
>> Adapted from the Linux driver (4.17)
>>
>> Changes from the original Linux driver:
>> * Removed HW spinlock mechanism, which is irrelevant
>> in U-boot particualar use case, which is just reading from the smem.
>> * adaptaion from Linux driver model to U-boot's.
>>
>> Cc: Bjorn Andersson 
>> Signed-off-by: Ramon Fried 
>> ---
>>
>
> 
>
>> +/* Pointer to the one and only smem handle */
>> +static struct qcom_smem *__smem;
>> +
>> +static int qcom_smem_alloc_private(struct qcom_smem *smem,
>> +struct smem_partition_header *phdr,
>> +unsigned item,
>> +size_t size)
>> +{
>
> 
>
>> +  */
>> + dmb();
>> + le32_add_cpu(&phdr->offset_free_uncached, alloc_size);
>
>
> drivers/soc/qualcomm/smem.c: In function ‘qcom_smem_alloc_private’:
> drivers/soc/qualcomm/smem.c:391:2: warning: implicit declaration of
> function ‘le32_add_cpu’ [-Wimplicit-function-declaration]
>   le32_add_cpu(&phdr->offset_free_uncached, alloc_size);
>
> Please, add the missing definition to
> ./include/linux/byteorder/generic.h
> or reference the prerequisite patch in the commit message.
Hi Heinrich, the prerequisite patch was mentioned in the cover letter.
I thought it's good enough, I can add it also to the commit message if
necessary.
Nevertheless, here it is:
https://patchwork.ozlabs.org/patch/924769/
Thanks,
Ramon.
>
> Best regards
>
> Heinrich
>
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/4] soc: qualcomm: Add Shared Memory Manager driver

2018-06-09 Thread Ramon Fried
On Sat, Jun 9, 2018 at 1:12 PM, Heinrich Schuchardt  wrote:
> On 06/09/2018 01:06 PM, Ramon Fried wrote:
>> The Shared Memory Manager driver implements an interface for allocating
>> and accessing items in the memory area shared among all of the
>> processors in a Qualcomm platform.
>>
>> Adapted from the Linux driver (4.17)
>
> Please, run scripts/checkpatch on this patch an fix all errors and
> warnings, e.g.
Hi Heinrich,
Actually I did run it, and I also run it in Linux and got the same results.
I thought it will be better to keep the driver aligned to Linux than
to fix these warnings.
But if can surely fix it, what do you suggest ?

>
> WARNING: line over 80 characters
> #1064: FILE: drivers/soc/qualcomm/smem.c:846:
> +   smem->regions[i].virt_base = devm_ioremap(dev, r.start,
> fdt_resource_size(&r));
>
> CHECK: Alignment should match open parenthesis
> #1098: FILE: drivers/soc/qualcomm/smem.c:880:
> +   if (num_regions > 1 && (ret = qcom_smem_map_memory(smem, dev,
> +   "qcom,rpm-msg-ram", 1)))
>
> Do not use DOS line endings.
Sure. Thanks.
>
> Best regards
>
> Heinrich Schuchardt
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/4] soc: qualcomm: Add Shared Memory Manager driver

2018-06-09 Thread Heinrich Schuchardt
On 06/09/2018 01:06 PM, Ramon Fried wrote:
> The Shared Memory Manager driver implements an interface for allocating
> and accessing items in the memory area shared among all of the
> processors in a Qualcomm platform.
> 
> Adapted from the Linux driver (4.17)
> 
> Changes from the original Linux driver:
> * Removed HW spinlock mechanism, which is irrelevant
> in U-boot particualar use case, which is just reading from the smem.
> * adaptaion from Linux driver model to U-boot's.
> 
> Cc: Bjorn Andersson 
> Signed-off-by: Ramon Fried 
> ---
> 



> +/* Pointer to the one and only smem handle */
> +static struct qcom_smem *__smem;
> +
> +static int qcom_smem_alloc_private(struct qcom_smem *smem,
> +struct smem_partition_header *phdr,
> +unsigned item,
> +size_t size)
> +{



> +  */
> + dmb();
> + le32_add_cpu(&phdr->offset_free_uncached, alloc_size);


drivers/soc/qualcomm/smem.c: In function ‘qcom_smem_alloc_private’:
drivers/soc/qualcomm/smem.c:391:2: warning: implicit declaration of
function ‘le32_add_cpu’ [-Wimplicit-function-declaration]
  le32_add_cpu(&phdr->offset_free_uncached, alloc_size);

Please, add the missing definition to
./include/linux/byteorder/generic.h
or reference the prerequisite patch in the commit message.

Best regards

Heinrich

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 2/4] soc: qualcomm: Add Shared Memory Manager driver

2018-06-09 Thread Heinrich Schuchardt
On 06/09/2018 01:06 PM, Ramon Fried wrote:
> The Shared Memory Manager driver implements an interface for allocating
> and accessing items in the memory area shared among all of the
> processors in a Qualcomm platform.
> 
> Adapted from the Linux driver (4.17)

Please, run scripts/checkpatch on this patch an fix all errors and
warnings, e.g.

WARNING: line over 80 characters
#1064: FILE: drivers/soc/qualcomm/smem.c:846:
+   smem->regions[i].virt_base = devm_ioremap(dev, r.start,
fdt_resource_size(&r));

CHECK: Alignment should match open parenthesis
#1098: FILE: drivers/soc/qualcomm/smem.c:880:
+   if (num_regions > 1 && (ret = qcom_smem_map_memory(smem, dev,
+   "qcom,rpm-msg-ram", 1)))

Do not use DOS line endings.

Best regards

Heinrich Schuchardt
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 2/4] soc: qualcomm: Add Shared Memory Manager driver

2018-06-09 Thread Ramon Fried
The Shared Memory Manager driver implements an interface for allocating
and accessing items in the memory area shared among all of the
processors in a Qualcomm platform.

Adapted from the Linux driver (4.17)

Changes from the original Linux driver:
* Removed HW spinlock mechanism, which is irrelevant
in U-boot particualar use case, which is just reading from the smem.
* adaptaion from Linux driver model to U-boot's.

Cc: Bjorn Andersson 
Signed-off-by: Ramon Fried 
---

 MAINTAINERS   |   1 +
 arch/arm/Kconfig  |   1 +
 drivers/Kconfig   |   2 +
 drivers/soc/Kconfig   |   5 +
 drivers/soc/Makefile  |   1 +
 drivers/soc/qualcomm/Kconfig  |  11 +
 drivers/soc/qualcomm/Makefile |   3 +
 drivers/soc/qualcomm/smem.c   | 934 ++
 8 files changed, 958 insertions(+)
 create mode 100644 drivers/soc/Kconfig
 create mode 100644 drivers/soc/qualcomm/Kconfig
 create mode 100644 drivers/soc/qualcomm/Makefile
 create mode 100644 drivers/soc/qualcomm/smem.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 642c448093..e57c5137d6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -187,6 +187,7 @@ ARM SNAPDRAGON
 M: Mateusz Kulikowski 
 S: Maintained
 F: arch/arm/mach-snapdragon/
+F: drivers/soc/qualcomm/
 
 ARM STI
 M: Patrice Chotard 
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index dde422bc5d..5af9aa78fc 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -728,6 +728,7 @@ config ARCH_SNAPDRAGON
select SPMI
select OF_CONTROL
select OF_SEPARATE
+   select MSM_SMEM
 
 config ARCH_SOCFPGA
bool "Altera SOCFPGA family"
diff --git a/drivers/Kconfig b/drivers/Kconfig
index 9e21b28750..d1167a3a4a 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -104,6 +104,8 @@ source "drivers/video/Kconfig"
 
 source "drivers/watchdog/Kconfig"
 
+source "drivers/soc/Kconfig"
+
 config PHYS_TO_BUS
bool "Custom physical to bus address mapping"
help
diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
new file mode 100644
index 00..79b88812ba
--- /dev/null
+++ b/drivers/soc/Kconfig
@@ -0,0 +1,5 @@
+menu "SOC (System On Chip) specific Drivers"
+
+source "drivers/soc/qualcomm/Kconfig"
+
+endmenu
diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
index d17f6ecaa0..781a6b73b2 100644
--- a/drivers/soc/Makefile
+++ b/drivers/soc/Makefile
@@ -3,4 +3,5 @@
 # Makefile for the U-Boot SOC specific device drivers.
 
 obj-$(CONFIG_ARCH_KEYSTONE)+= keystone/
+obj-$(CONFIG_ARCH_SNAPDRAGON)  += qualcomm/
 obj-y += soc-uclass.o
diff --git a/drivers/soc/qualcomm/Kconfig b/drivers/soc/qualcomm/Kconfig
new file mode 100644
index 00..aeeaf2bb10
--- /dev/null
+++ b/drivers/soc/qualcomm/Kconfig
@@ -0,0 +1,11 @@
+menu "Qualcomm SoC drivers"
+
+config MSM_SMEM
+   bool "Qualcomm Shared Memory Manager (SMEM)"
+   depends on ARCH_SNAPDRAGON
+   help
+ Say y here to enable support for the Qualcomm Shared Memory Manager.
+ The driver provides an interface to items in a heap shared among all
+ processors in a Qualcomm platform.
+
+endmenu
diff --git a/drivers/soc/qualcomm/Makefile b/drivers/soc/qualcomm/Makefile
new file mode 100644
index 00..833944a315
--- /dev/null
+++ b/drivers/soc/qualcomm/Makefile
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-$(CONFIG_MSM_SMEM) += smem.o
diff --git a/drivers/soc/qualcomm/smem.c b/drivers/soc/qualcomm/smem.c
new file mode 100644
index 00..416538ba3b
--- /dev/null
+++ b/drivers/soc/qualcomm/smem.c
@@ -0,0 +1,934 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2015, Sony Mobile Communications AB.
+ * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2018, Ramon Fried 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * The Qualcomm shared memory system is an allocate only heap structure that
+ * consists of one of more memory areas that can be accessed by the processors
+ * in the SoC.
+ *
+ * All systems contains a global heap, accessible by all processors in the SoC,
+ * with a table of contents data structure (@smem_header) at the beginning of
+ * the main shared memory block.
+ *
+ * The global header contains meta data for allocations as well as a fixed list
+ * of 512 entries (@smem_global_entry) that can be initialized to reference
+ * parts of the shared memory space.
+ *
+ *
+ * In addition t