2013-06-17 17:56:28

by Rafał Miłecki

[permalink] [raw]
Subject: [PATCH] ssb: add struct for serial flash

This data allow writing for example MTD driver.

Signed-off-by: Rafał Miłecki <[email protected]>
---
drivers/ssb/driver_chipcommon_sflash.c | 7 +++++++
include/linux/ssb/ssb_driver_mips.h | 15 +++++++++++++++
2 files changed, 22 insertions(+)

diff --git a/drivers/ssb/driver_chipcommon_sflash.c b/drivers/ssb/driver_chipcommon_sflash.c
index 1b9e770..205f1c4 100644
--- a/drivers/ssb/driver_chipcommon_sflash.c
+++ b/drivers/ssb/driver_chipcommon_sflash.c
@@ -73,6 +73,7 @@ static void ssb_sflash_cmd(struct ssb_chipcommon *cc, u32 opcode)
/* Initialize serial flash access */
int ssb_sflash_init(struct ssb_chipcommon *cc)
{
+ struct ssb_sflash *sflash = &cc->dev->bus->mipscore.sflash;
const struct ssb_sflash_tbl_e *e;
u32 id, id2;

@@ -131,6 +132,12 @@ int ssb_sflash_init(struct ssb_chipcommon *cc)
return -ENOTSUPP;
}

+ sflash->window = SSB_FLASH2;
+ sflash->blocksize = e->blocksize;
+ sflash->numblocks = e->numblocks;
+ sflash->size = sflash->blocksize * sflash->numblocks;
+ sflash->present = true;
+
pr_info("Found %s serial flash (blocksize: 0x%X, blocks: %d)\n",
e->name, e->blocksize, e->numblocks);

diff --git a/include/linux/ssb/ssb_driver_mips.h b/include/linux/ssb/ssb_driver_mips.h
index afe79d4..6535e47 100644
--- a/include/linux/ssb/ssb_driver_mips.h
+++ b/include/linux/ssb/ssb_driver_mips.h
@@ -20,6 +20,18 @@ struct ssb_pflash {
u32 window_size;
};

+#ifdef CONFIG_SSB_SFLASH
+struct ssb_sflash {
+ bool present;
+ u32 window;
+ u32 blocksize;
+ u16 numblocks;
+ u32 size;
+
+ void *priv;
+};
+#endif
+
struct ssb_mipscore {
struct ssb_device *dev;

@@ -27,6 +39,9 @@ struct ssb_mipscore {
struct ssb_serial_port serial_ports[4];

struct ssb_pflash pflash;
+#ifdef CONFIG_SSB_SFLASH
+ struct ssb_sflash sflash;
+#endif
};

extern void ssb_mipscore_init(struct ssb_mipscore *mcore);
--
1.7.10.4



2013-06-17 20:40:34

by Rafał Miłecki

[permalink] [raw]
Subject: Re: [PATCH] ssb: add struct for serial flash

2013/6/17 Rafał Miłecki <[email protected]>:
> 2013/6/17 Rafał Miłecki <[email protected]>:
>> This data allow writing for example MTD driver.
>
> To make this a bit more clear:
>
> Up until now, we were detecting flash model in
> driver_chipcommon_sflash.c, but nothing more than that. It was printed
> and that's all. Noone could read it's details or/and use it.
>
> As providing an access to the flash is usually a good idea, we need an
> additional MTD driver for it. Such MTD driver needs some basic info
> about flash. It's mapping address and size at least.

As an example you can see drivers/mtd/devices/bcm47xxsflash.c which a
driver for "bcma_sflash" platform device.

--
Rafał

2013-06-17 20:33:10

by Rafał Miłecki

[permalink] [raw]
Subject: Re: [PATCH] ssb: add struct for serial flash

2013/6/17 Rafał Miłecki <[email protected]>:
> 2013/6/17 Florian Fainelli <[email protected]>:
>> Hello Rafal,
>>
>> Le lundi 17 juin 2013 18:56:20, Rafał Miłecki a écrit :
>>> This data allow writing for example MTD driver.
>>
>> Your commit message could probably have some more information, by looking at
>> the patch, it is not entirely clear to me what this does, especially as sflash
>> is just a write only structure?
>
> OK, no problem. I'll give people w little more time for comments, and
> then I'll submit next version.

It's already in wireless-next, so I'll explain this just in an e-mail.
There is not much more to explain anyway ;)

--
Rafał

2013-06-17 19:46:09

by Rafał Miłecki

[permalink] [raw]
Subject: Re: [PATCH] ssb: add struct for serial flash

2013/6/17 Florian Fainelli <[email protected]>:
> Hello Rafal,
>
> Le lundi 17 juin 2013 18:56:20, Rafał Miłecki a écrit :
>> This data allow writing for example MTD driver.
>
> Your commit message could probably have some more information, by looking at
> the patch, it is not entirely clear to me what this does, especially as sflash
> is just a write only structure?

OK, no problem. I'll give people w little more time for comments, and
then I'll submit next version.

--
Rafał

2013-06-17 20:38:42

by Rafał Miłecki

[permalink] [raw]
Subject: Re: [PATCH] ssb: add struct for serial flash

2013/6/17 Rafał Miłecki <[email protected]>:
> This data allow writing for example MTD driver.

To make this a bit more clear:

Up until now, we were detecting flash model in
driver_chipcommon_sflash.c, but nothing more than that. It was printed
and that's all. Noone could read it's details or/and use it.

As providing an access to the flash is usually a good idea, we need an
additional MTD driver for it. Such MTD driver needs some basic info
about flash. It's mapping address and size at least.
With this patch we put all important data in struct ssb_sflash. It can
be accessed in two possible ways:
1) With the: bus->mipscore.sflash path. How to get a reference to the
"bus"? It's an static exported symbols on some archs (bcm47xx).
2) Directly, it "sflash" is registered as a platform driver data. My
next patch will address that.

--
Rafał

2013-06-17 21:09:37

by Florian Fainelli

[permalink] [raw]
Subject: Re: [PATCH] ssb: add struct for serial flash

Le lundi 17 juin 2013 21:38:42, Rafał Miłecki a écrit :
> 2013/6/17 Rafał Miłecki <[email protected]>:
> > This data allow writing for example MTD driver.
>
> To make this a bit more clear:
>
> Up until now, we were detecting flash model in
> driver_chipcommon_sflash.c, but nothing more than that. It was printed
> and that's all. Noone could read it's details or/and use it.
>
> As providing an access to the flash is usually a good idea, we need an
> additional MTD driver for it. Such MTD driver needs some basic info
> about flash. It's mapping address and size at least.
> With this patch we put all important data in struct ssb_sflash. It can
> be accessed in two possible ways:
> 1) With the: bus->mipscore.sflash path. How to get a reference to the
> "bus"? It's an static exported symbols on some archs (bcm47xx).
> 2) Directly, it "sflash" is registered as a platform driver data. My
> next patch will address that.

Ok, well this was probably worth a cover letter just for this, and the second
patch to be posted too ;) Thanks for the explanation


--
Florian

2013-06-17 19:38:38

by Florian Fainelli

[permalink] [raw]
Subject: Re: [PATCH] ssb: add struct for serial flash

Hello Rafal,

Le lundi 17 juin 2013 18:56:20, Rafał Miłecki a écrit :
> This data allow writing for example MTD driver.

Your commit message could probably have some more information, by looking at
the patch, it is not entirely clear to me what this does, especially as sflash
is just a write only structure?

>
> Signed-off-by: Rafał Miłecki <[email protected]>
> ---
> drivers/ssb/driver_chipcommon_sflash.c | 7 +++++++
> include/linux/ssb/ssb_driver_mips.h | 15 +++++++++++++++
> 2 files changed, 22 insertions(+)
>
> diff --git a/drivers/ssb/driver_chipcommon_sflash.c
> b/drivers/ssb/driver_chipcommon_sflash.c index 1b9e770..205f1c4 100644
> --- a/drivers/ssb/driver_chipcommon_sflash.c
> +++ b/drivers/ssb/driver_chipcommon_sflash.c
> @@ -73,6 +73,7 @@ static void ssb_sflash_cmd(struct ssb_chipcommon *cc, u32
> opcode) /* Initialize serial flash access */
> int ssb_sflash_init(struct ssb_chipcommon *cc)
> {
> + struct ssb_sflash *sflash = &cc->dev->bus->mipscore.sflash;
> const struct ssb_sflash_tbl_e *e;
> u32 id, id2;
>
> @@ -131,6 +132,12 @@ int ssb_sflash_init(struct ssb_chipcommon *cc)
> return -ENOTSUPP;
> }
>
> + sflash->window = SSB_FLASH2;
> + sflash->blocksize = e->blocksize;
> + sflash->numblocks = e->numblocks;
> + sflash->size = sflash->blocksize * sflash->numblocks;
> + sflash->present = true;
> +
> pr_info("Found %s serial flash (blocksize: 0x%X, blocks: %d)\n",
> e->name, e->blocksize, e->numblocks);
>
> diff --git a/include/linux/ssb/ssb_driver_mips.h
> b/include/linux/ssb/ssb_driver_mips.h index afe79d4..6535e47 100644
> --- a/include/linux/ssb/ssb_driver_mips.h
> +++ b/include/linux/ssb/ssb_driver_mips.h
> @@ -20,6 +20,18 @@ struct ssb_pflash {
> u32 window_size;
> };
>
> +#ifdef CONFIG_SSB_SFLASH
> +struct ssb_sflash {
> + bool present;
> + u32 window;
> + u32 blocksize;
> + u16 numblocks;
> + u32 size;
> +
> + void *priv;
> +};
> +#endif
> +
> struct ssb_mipscore {
> struct ssb_device *dev;
>
> @@ -27,6 +39,9 @@ struct ssb_mipscore {
> struct ssb_serial_port serial_ports[4];
>
> struct ssb_pflash pflash;
> +#ifdef CONFIG_SSB_SFLASH
> + struct ssb_sflash sflash;
> +#endif
> };
>
> extern void ssb_mipscore_init(struct ssb_mipscore *mcore);

--
Florian