From: Anton Vorontsov <hidden> Date: 2008-10-30 19:55:57
Hi all,
Here are the bindings, again. Still RFC.
This patch series depends on:
http://lkml.org/lkml/2008/10/16/250http://lkml.org/lkml/2008/10/24/416
+ of_gpio_flags enum (Trent Piepho will post an updated patch soon,
I believe).
Pierre, the approach is somewhat similar to this one:
http://lkml.org/lkml/2008/5/26/135
Posted few months ago.
I know you don't like it, but I ask you to reconsider it. The
I2C and SPI cases are similar, and recently we tried to write
bindings for some I2C GPIO controllers.
There we've learned that we:
1. Don't like the bus notifiers approach b/c we can't place the OF
code into the module.
http://lkml.org/lkml/2008/10/21/425
Hacks are possible, but they're are ugly.
2. Don't want to write new drivers to solely handle the platform
data:
http://lkml.org/lkml/2008/10/28/257http://lkml.org/lkml/2008/10/28/268
And personally I don't want to do refactoring for every driver that
we'd want to use with the OpenFirmware...
If I understood correctly, for GPIO controllers David agreed that
we can live with the platform data accessors, at least for now:
http://lkml.org/lkml/2008/10/23/24
And when/if we'll find something better I'll be the first who
will offer help to convert the bindings code to this "something
better".
Thanks,
--
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2
From: Anton Vorontsov <hidden> Date: 2008-10-30 19:56:41
The bindings describes a case where MMC/SD/SDIO slot directly connected
to a SPI bus. Such setups are widely used on embedded PowerPC boards.
The patch also adds the mmc-spi-slot entry to the OpenFirmware modalias
table.
Signed-off-by: Anton Vorontsov <redacted>
---
.../powerpc/dts-bindings/mmc-spi-slot.txt | 23 ++++++++++++++++++++
drivers/of/base.c | 1 +
2 files changed, 24 insertions(+), 0 deletions(-)
create mode 100644 Documentation/powerpc/dts-bindings/mmc-spi-slot.txt
@@ -0,0 +1,23 @@+MMC/SD/SDIO slot directly connected to a SPI bus++Required properties:+- compatible : should be "mmc-spi-slot".+- reg : should specify SPI address (chip-select number).+- spi-max-frequency : maximum frequency for this device (Hz).+- voltage-ranges : two cells are required, first cell specifies minimum+ slot voltage (mV), second cell specifies maximum slot voltage (mV).+ Several ranges could be specified.+- gpios : (optional) may specify GPIOs in this order: Card-Detect GPIO,+ Write-Protect GPIO.++Example:++ mmc-slot@0 {+ compatible = "fsl,mpc8323rdb-mmc-slot",+ "mmc-spi-slot";+ reg = <0>;+ gpios = <&qe_pio_d 14 1+ &qe_pio_d 15 0>;+ voltage-ranges = <3300 3300>;+ spi-max-frequency = <50000000>;+ };
From: Grant Likely <hidden> Date: 2008-10-30 20:37:41
On Thu, Oct 30, 2008 at 1:56 PM, Anton Vorontsov
[off-list ref] wrote:
The bindings describes a case where MMC/SD/SDIO slot directly connected
to a SPI bus. Such setups are widely used on embedded PowerPC boards.
The patch also adds the mmc-spi-slot entry to the OpenFirmware modalias
table.
Signed-off-by: Anton Vorontsov <redacted>
@@ -0,0 +1,23 @@+MMC/SD/SDIO slot directly connected to a SPI bus++Required properties:+- compatible : should be "mmc-spi-slot".+- reg : should specify SPI address (chip-select number).+- spi-max-frequency : maximum frequency for this device (Hz).+- voltage-ranges : two cells are required, first cell specifies minimum+ slot voltage (mV), second cell specifies maximum slot voltage (mV).+ Several ranges could be specified.+- gpios : (optional) may specify GPIOs in this order: Card-Detect GPIO,+ Write-Protect GPIO.
I wonder if we're following the example of irq mappings too closely
for the gpios property. I like the layout of the property
(<controller> <specifier>), but I think the 'gpios' name is getting
too overloaded. In this case a single property 'gpios' is being used
to encode 2 unrelated bits of information; the write protect pin and
the card detect pins.
In this particular case I think it is better to use 2 properties in
this case; something like 'spi-writeprotect-gpio' and
'spi-carddetect-gpio' using the same specifier format. Doing so adds
a bit more clarity to the purpose of the properties.
I my mind I differentiate this from other examples (for instance a
series of CS pins) based on how closely related the pin functions are.
So I would say for the following examples...
1) GPIO data bus (SPI, MDIO and I2C are great examples); all pins must
be present - single gpio property
2) This MMC case (pins are optional and unrelated); separate gpio properties
3) LCD with backlight and contrast control pins; one gpio property for
backlight pins, one for constrast pins.
Thoughts?
From: Anton Vorontsov <hidden> Date: 2008-10-30 23:03:14
On Thu, Oct 30, 2008 at 02:37:31PM -0600, Grant Likely wrote:
[...]
quoted
+- gpios : (optional) may specify GPIOs in this order: Card-Detect GPIO,
+ Write-Protect GPIO.
I wonder if we're following the example of irq mappings too closely
for the gpios property. I like the layout of the property
(<controller> <specifier>), but I think the 'gpios' name is getting
too overloaded. In this case a single property 'gpios' is being used
to encode 2 unrelated bits of information; the write protect pin and
the card detect pins.
In this particular case I think it is better to use 2 properties in
this case; something like 'spi-writeprotect-gpio' and
'spi-carddetect-gpio' using the same specifier format. Doing so adds
a bit more clarity to the purpose of the properties.
I my mind I differentiate this from other examples (for instance a
series of CS pins) based on how closely related the pin functions are.
So I would say for the following examples...
1) GPIO data bus (SPI, MDIO and I2C are great examples); all pins must
be present - single gpio property
2) This MMC case (pins are optional and unrelated); separate gpio properties
3) LCD with backlight and contrast control pins; one gpio property for
backlight pins, one for constrast pins.
Thoughts?
It's pretty trivial to implement (of_get_named_gpio() -- could be just
factored out of of_get_gpio()).
Though,
1. The idea is quite extreme. It needs discussion, and furthermore,
we need to define when do we use gpios = <> and when something-gpio =
<>; We need to be consistent, and to be consistent, the rules should
be clear and written.
2. We should think about it very very carefully. Do we want to lose the
track of gpios? For example, there are quite defined rules when (and
in what properties) you may encounter memory addresses, when and
where you can encounter interrupt specifiers. We do the same for
gpios, and so far it works great. We need to think about any possible
drawbacks of the scheme you purpose (we would never know where to
expect gpios - it isn't a problem per se, but maybe it could lead
to some problem in future? I don't know.)
Quite honestly I don't like the idea... maybe I just used to
interrupts = <>, reg = <>, ranges = <>, interrupt-map = <> and so
forth, and now my subconsciousness tells me "it's wrong to do
something-interrupt = <> stuff." ;-)
Anyway, your proposal is forward and backward compatible with the
existing scheme, and can even coexist. Thus I'd prefer to stay with
the today's gpios = <>. We can always start use the new scheme when
it will be thought out enough.
Thanks,
p.s. I'd prefer a new thread for this discussion, somewhere
in devicetree-discuss@ozlabs.org, so that it won't relate to this
particular patch.
--
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2
From: Anton Vorontsov <hidden> Date: 2008-10-30 23:29:07
On Fri, Oct 31, 2008 at 02:02:53AM +0300, Anton Vorontsov wrote:
[...]
It's pretty trivial to implement (of_get_named_gpio() -- could be just
factored out of of_get_gpio()).
Though,
1. The idea is quite extreme. It needs discussion, and furthermore,
we need to define when do we use gpios = <> and when something-gpio =
<>; We need to be consistent, and to be consistent, the rules should
be clear and written.
2. We should think about it very very carefully. Do we want to lose the
track of gpios? For example, there are quite defined rules when (and
in what properties) you may encounter memory addresses, when and
where you can encounter interrupt specifiers. We do the same for
gpios, and so far it works great. We need to think about any possible
drawbacks of the scheme you purpose (we would never know where to
expect gpios - it isn't a problem per se, but maybe it could lead
to some problem in future? I don't know.)
Quite honestly I don't like the idea... maybe I just used to
interrupts = <>, reg = <>, ranges = <>, interrupt-map = <> and so
forth, and now my subconsciousness tells me "it's wrong to do
something-interrupt = <> stuff." ;-)
Btw, not that I hate this new scheme, sometimes the scheme is even
inevitable. For example when we have gpios with two or more ellipsis:
gpios = <... ...>.
But this should be a separate discussion, really.
--
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2
From: David Gibson <hidden> Date: 2008-10-31 01:24:13
On Fri, Oct 31, 2008 at 02:02:53AM +0300, Anton Vorontsov wrote:
On Thu, Oct 30, 2008 at 02:37:31PM -0600, Grant Likely wrote:
[...]
quoted
quoted
+- gpios : (optional) may specify GPIOs in this order: Card-Detect GPIO,
+ Write-Protect GPIO.
I wonder if we're following the example of irq mappings too closely
for the gpios property. I like the layout of the property
(<controller> <specifier>), but I think the 'gpios' name is getting
too overloaded. In this case a single property 'gpios' is being used
to encode 2 unrelated bits of information; the write protect pin and
the card detect pins.
In this particular case I think it is better to use 2 properties in
this case; something like 'spi-writeprotect-gpio' and
'spi-carddetect-gpio' using the same specifier format. Doing so adds
a bit more clarity to the purpose of the properties.
I my mind I differentiate this from other examples (for instance a
series of CS pins) based on how closely related the pin functions are.
So I would say for the following examples...
1) GPIO data bus (SPI, MDIO and I2C are great examples); all pins must
be present - single gpio property
2) This MMC case (pins are optional and unrelated); separate gpio properties
3) LCD with backlight and contrast control pins; one gpio property for
backlight pins, one for constrast pins.
Thoughts?
It's pretty trivial to implement (of_get_named_gpio() -- could be just
factored out of of_get_gpio()).
Though,
1. The idea is quite extreme. It needs discussion, and furthermore,
we need to define when do we use gpios = <> and when something-gpio =
<>; We need to be consistent, and to be consistent, the rules should
be clear and written.
2. We should think about it very very carefully. Do we want to lose the
track of gpios? For example, there are quite defined rules when (and
in what properties) you may encounter memory addresses, when and
where you can encounter interrupt specifiers. We do the same for
gpios, and so far it works great. We need to think about any possible
drawbacks of the scheme you purpose (we would never know where to
expect gpios - it isn't a problem per se, but maybe it could lead
to some problem in future? I don't know.)
Quite honestly I don't like the idea... maybe I just used to
interrupts = <>, reg = <>, ranges = <>, interrupt-map = <> and so
forth, and now my subconsciousness tells me "it's wrong to do
something-interrupt = <> stuff." ;-)
Fwiw, I agree. The current scheme works, adding new places to look
for gpio specifiers will just complexify things. Long lists of gpios
may be somewhat awkward to work with, but I don't think it's
sufficiently bad to warrant another scheme.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
From: Anton Vorontsov <hidden> Date: 2008-10-30 19:56:55
This function sets the OCR mask bits according to provided voltage
ranges. Will be used by the mmc_spi OpenFirmware bindings.
Signed-off-by: Anton Vorontsov <redacted>
---
drivers/mmc/core/core.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++
include/linux/mmc/core.h | 3 ++
2 files changed, 58 insertions(+), 0 deletions(-)
@@ -444,6 +445,60 @@ void mmc_set_bus_width(struct mmc_host *host, unsigned int width)mmc_set_ios(host);}+staticintmmc_vdd_to_ocrbit(intvdd)+{+intbit;+constintmax_bit=ilog2(MMC_VDD_35_36);++if(vdd<1650||vdd>3600)+return-EINVAL;++if(vdd>=1650&&vdd<=1950)+returnilog2(MMC_VDD_165_195);++/* base 2000 mV, step 100 mV, bit's base 8 */+bit=(vdd-2000)/100+8;+if(bit>max_bit)+returnmax_bit;+returnbit;+}++/**+*mmc_vddrange_to_ocrmask-ConvertavoltagerangetotheOCRmask+*@vdd_min:minimumvoltagevalue(mV)+*@vdd_max:maximumvoltagevalue(mV)+*@mask:pointertothemask+*+*ThisfunctionsetstheOCRmaskbitsaccordingtotheprovided@vdd_min+*and@vdd_maxvalues.+*+*NOTE:You_must_setthemaskvalueto0beforecallingthisfunctionthe+*firsttime.Thisisdonesothatyoucancallthisfunctionseveral+*timestosetOCRmaskfordiscontinuousvoltageranges.+*+*Thefunctionreturns0onsuccessandanegativeerrnovaluewhen+*aconversionisnotpossible.+*/+intmmc_vddrange_to_ocrmask(intvdd_min,intvdd_max,unsignedint*mask)+{+if(vdd_max<vdd_min)+return-EINVAL;++vdd_max=mmc_vdd_to_ocrbit(vdd_max);+if(vdd_max<0)+return-EINVAL;++vdd_min=mmc_vdd_to_ocrbit(vdd_min);+if(vdd_min<0)+return-EINVAL;++/* fill the mask, from max bit to min bit */+while(vdd_max>=vdd_min)+*mask|=1<<vdd_max--;+return0;+}+EXPORT_SYMBOL(mmc_vddrange_to_ocrmask);+/**Maskoffanyvoltageswedon'tsupportandselect*thelowestvoltage
From: Pierre Ossman <hidden> Date: 2008-11-08 20:55:57
On Thu, 30 Oct 2008 22:56:32 +0300
Anton Vorontsov [off-list ref] wrote:
+/**
+ * mmc_vddrange_to_ocrmask - Convert a voltage range to the OCR mask
+ * @vdd_min: minimum voltage value (mV)
+ * @vdd_max: maximum voltage value (mV)
+ * @mask: pointer to the mask
+ *
Why the pointer? Why not let the caller handle the aggregation? That
would be a lot safer.
+ /* fill the mask, from max bit to min bit */
+ while (vdd_max >= vdd_min)
+ *mask |= 1 << vdd_max--;
+ return 0;
Many cards get a bit uppity with a single bit set. If possible, try to
make this function set two bits when the voltage is right on the
boundary (e.g. 3.3V).
Rgds
--
-- Pierre Ossman
Linux kernel, MMC maintainer http://www.kernel.org
rdesktop, core developer http://www.rdesktop.org
WARNING: This correspondence is being monitored by the
Swedish government. Make sure your server uses encryption
for SMTP traffic and consider using PGP for end-to-end
encryption.
From: Anton Vorontsov <hidden> Date: 2008-11-26 19:54:29
This function sets the OCR mask bits according to provided voltage
ranges. Will be used by the mmc_spi OpenFirmware bindings.
Signed-off-by: Anton Vorontsov <redacted>
---
Hi Pierre,
Sorry for the delay.
On Sat, Nov 08, 2008 at 09:55:37PM +0100, Pierre Ossman wrote:
On Thu, 30 Oct 2008 22:56:32 +0300
Anton Vorontsov [off-list ref] wrote:
quoted
+/**
+ * mmc_vddrange_to_ocrmask - Convert a voltage range to the OCR mask
+ * @vdd_min: minimum voltage value (mV)
+ * @vdd_max: maximum voltage value (mV)
+ * @mask: pointer to the mask
+ *
Why the pointer? Why not let the caller handle the aggregation? That
would be a lot safer.
Yeah, makes sense. Now the function returns OCR mask, or 0 on error.
quoted
+ /* fill the mask, from max bit to min bit */
+ while (vdd_max >= vdd_min)
+ *mask |= 1 << vdd_max--;
+ return 0;
Many cards get a bit uppity with a single bit set. If possible, try to
make this function set two bits when the voltage is right on the
boundary (e.g. 3.3V).
Something like this patch (the boundary cases are documented now)?
p.s. If the patch is OK I'll respin the whole patchset.
drivers/mmc/core/core.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++
include/linux/mmc/core.h | 2 +
2 files changed, 77 insertions(+), 0 deletions(-)
@@ -444,6 +445,80 @@ void mmc_set_bus_width(struct mmc_host *host, unsigned int width)mmc_set_ios(host);}+/**+*mmc_vdd_to_ocrbitnum-ConvertavoltagetotheOCRbitnumber+*@vdd:voltage(mV)+*@low_bits:preferlowbitsinboundarycases+*+*ThisfunctionreturnstheOCRbitnumberaccordingtotheprovided@vdd+*value.Ifconversionisnotpossibleanegativeerrnovaluereturned.+*+*Dependingonthe@low_bitsflagthefunctionprefersloworhighOCRbits+*onboundaryvoltages.Forexample,+*with@low_bits=true,3300mVtranslatestoilog2(MMC_VDD_32_33);+*with@low_bits=false,3300mVtranslatestoilog2(MMC_VDD_33_34);+*+*Anyvalueinthe[1951:1999]rangetranslatestotheilog2(MMC_VDD_20_21).+*/+staticintmmc_vdd_to_ocrbitnum(intvdd,boollow_bits)+{+constintmax_bit=ilog2(MMC_VDD_35_36);+intbit;++if(vdd<1650||vdd>3600)+return-EINVAL;++if(vdd>=1650&&vdd<=1950)+returnilog2(MMC_VDD_165_195);++if(low_bits)+vdd-=1;++/* Base 2000 mV, step 100 mV, bit's base 8. */+bit=(vdd-2000)/100+8;+if(bit>max_bit)+returnmax_bit;+returnbit;+}++/**+*mmc_vddrange_to_ocrmask-ConvertavoltagerangetotheOCRmask+*@vdd_min:minimumvoltagevalue(mV)+*@vdd_max:maximumvoltagevalue(mV)+*+*ThisfunctionreturnstheOCRmaskbitsaccordingtotheprovided@vdd_min+*and@vdd_maxvalues.Ifconversionisnotpossiblethefunctionreturns0.+*+*Noteswrtboundarycases:+*ThisfunctionsetstheOCRbitsforallboundaryvoltages,forexample+*[3300:3400]rangeistranslatedtoMMC_VDD_32_33|MMC_VDD_33_34|+*MMC_VDD_34_35mask.+*/+u32mmc_vddrange_to_ocrmask(intvdd_min,intvdd_max)+{+u32mask=0;++if(vdd_max<vdd_min)+return0;++/* Prefer high bits for the boundary vdd_max values. */+vdd_max=mmc_vdd_to_ocrbitnum(vdd_max,false);+if(vdd_max<0)+return0;++/* Prefer low bits for the boundary vdd_min values. */+vdd_min=mmc_vdd_to_ocrbitnum(vdd_min,true);+if(vdd_min<0)+return0;++/* Fill the mask, from max bit to min bit. */+while(vdd_max>=vdd_min)+mask|=1<<vdd_max--;++returnmask;+}+EXPORT_SYMBOL(mmc_vddrange_to_ocrmask);+/**Maskoffanyvoltageswedon'tsupportandselect*thelowestvoltage
From: Pierre Ossman <hidden> Date: 2008-11-30 20:07:06
On Wed, 26 Nov 2008 22:54:17 +0300
Anton Vorontsov [off-list ref] wrote:
This function sets the OCR mask bits according to provided voltage
ranges. Will be used by the mmc_spi OpenFirmware bindings.
Signed-off-by: Anton Vorontsov <redacted>
---
Hi Pierre,
Sorry for the delay.
This looks perfect. Just tell me when you want me to queue it up.
Rgds
--
-- Pierre Ossman
Linux kernel, MMC maintainer http://www.kernel.org
rdesktop, core developer http://www.rdesktop.org
WARNING: This correspondence is being monitored by the
Swedish government. Make sure your server uses encryption
for SMTP traffic and consider using PGP for end-to-end
encryption.
From: Anton Vorontsov <hidden> Date: 2008-12-01 11:53:31
On Sun, Nov 30, 2008 at 09:06:48PM +0100, Pierre Ossman wrote:
On Wed, 26 Nov 2008 22:54:17 +0300
Anton Vorontsov [off-list ref] wrote:
quoted
This function sets the OCR mask bits according to provided voltage
ranges. Will be used by the mmc_spi OpenFirmware bindings.
Signed-off-by: Anton Vorontsov <redacted>
---
Hi Pierre,
Sorry for the delay.
This looks perfect. Just tell me when you want me to queue it up.
I plan resend the series (OF MMC SPI) some time between 2.6.28-rc0
and -rc1, that is, when all needed powerpc patches will be merged
into the Linus' tree.
Though, the $subject patch could be merged anytime as it doesn't
depend on anything else. So, if you'll merge it earlier, that will
make things a bit easier: -1 patch to resend. ;-)
Thanks,
--
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2
From: Pierre Ossman <hidden> Date: 2008-12-14 17:28:49
On Mon, 1 Dec 2008 14:53:20 +0300
Anton Vorontsov [off-list ref] wrote:
Though, the $subject patch could be merged anytime as it doesn't
depend on anything else. So, if you'll merge it earlier, that will
make things a bit easier: -1 patch to resend. ;-)
Queued up. Will be sent once the merge window opens up.
Rgds
--
-- Pierre Ossman
Linux kernel, MMC maintainer http://www.kernel.org
rdesktop, core developer http://www.rdesktop.org
WARNING: This correspondence is being monitored by the
Swedish government. Make sure your server uses encryption
for SMTP traffic and consider using PGP for end-to-end
encryption.
From: Anton Vorontsov <hidden> Date: 2008-10-30 19:57:18
The support is implemented via platform data accessors, new module
(of_mmc_spi) will be created automatically when the driver compiles
on OpenFirmware platforms. Link-time dependency will load the module
automatically.
Signed-off-by: Anton Vorontsov <redacted>
---
drivers/mmc/host/Makefile | 3 +
drivers/mmc/host/mmc_spi.c | 4 +-
drivers/mmc/host/of_mmc_spi.c | 147 +++++++++++++++++++++++++++++++++++++++++
include/linux/spi/mmc_spi.h | 8 ++
4 files changed, 161 insertions(+), 1 deletions(-)
create mode 100644 drivers/mmc/host/of_mmc_spi.c
@@ -1285,7 +1285,7 @@ static int mmc_spi_probe(struct spi_device *spi)/* Platform data is used to hook up things like card sensing*andpowerswitchinggpios.*/-host->pdata=spi->dev.platform_data;+host->pdata=mmc_spi_get_pdata(spi);if(host->pdata)mmc->ocr_avail=host->pdata->ocr_mask;if(!mmc->ocr_avail){
From: Pierre Ossman <hidden> Date: 2008-11-08 20:51:19
On Thu, 30 Oct 2008 22:55:46 +0300
Anton Vorontsov [off-list ref] wrote:
Pierre, the approach is somewhat similar to this one:
http://lkml.org/lkml/2008/5/26/135
Posted few months ago.
I know you don't like it, but I ask you to reconsider it. The
I2C and SPI cases are similar, and recently we tried to write
bindings for some I2C GPIO controllers.
This new version is a bit better in that you've generalised thing more.
I'd still prefer if we can have an interface where the driver doesn't
have to know that it is on an ACPI/OF/EFI/whatnot host, but I can live
with this model for now.
Rgds
--
-- Pierre Ossman
Linux kernel, MMC maintainer http://www.kernel.org
rdesktop, core developer http://www.rdesktop.org
WARNING: This correspondence is being monitored by the
Swedish government. Make sure your server uses encryption
for SMTP traffic and consider using PGP for end-to-end
encryption.