Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1270847 > unrolled thread
| Started by | Cory Tusar <cory.tusar@pid1solutions.com> |
|---|---|
| First post | 2015-11-17 05:20 +0100 |
| Last post | 2015-11-17 05:20 +0100 |
| Articles | 13 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH 0/7] Devicetree support for misc/eeprom/eeprom_93xx46. Cory Tusar <cory.tusar@pid1solutions.com> - 2015-11-17 05:20 +0100
[PATCH 4/7] misc: eeprom: 93xx46: Add DT binding for Atmel AT93C46D devices. Cory Tusar <cory.tusar@pid1solutions.com> - 2015-11-17 05:20 +0100
Re: [PATCH 4/7] misc: eeprom: 93xx46: Add DT binding for Atmel AT93C46D devices. Rob Herring <robh@kernel.org> - 2015-11-17 22:00 +0100
Re: [PATCH 4/7] misc: eeprom: 93xx46: Add DT binding for Atmel AT93C46D devices. Cory Tusar <cory.tusar@pid1solutions.com> - 2015-11-17 22:20 +0100
[PATCH 5/7] misc: eeprom: 93xx46: Add quirks to support Atmel AT93C46D device. Cory Tusar <cory.tusar@pid1solutions.com> - 2015-11-17 05:20 +0100
[PATCH 6/7] misc: eeprom: 93xx46: Add DT binding for a GPIO 'select' line. Cory Tusar <cory.tusar@pid1solutions.com> - 2015-11-17 05:20 +0100
Re: [PATCH 6/7] misc: eeprom: 93xx46: Add DT binding for a GPIO 'select' line. Rob Herring <robh@kernel.org> - 2015-11-17 22:00 +0100
Re: [PATCH 6/7] misc: eeprom: 93xx46: Add DT binding for a GPIO 'select' line. Cory Tusar <cory.tusar@pid1solutions.com> - 2015-11-17 22:20 +0100
[PATCH 2/7] misc: eeprom: 93xx46: Add DT bindings to eeprom_93xx46 driver. Cory Tusar <cory.tusar@pid1solutions.com> - 2015-11-17 05:20 +0100
Re: [PATCH 2/7] misc: eeprom: 93xx46: Add DT bindings to eeprom_93xx46 driver. Rob Herring <robh@kernel.org> - 2015-11-17 22:00 +0100
Re: [PATCH 2/7] misc: eeprom: 93xx46: Add DT bindings to eeprom_93xx46 driver. Cory Tusar <cory.tusar@pid1solutions.com> - 2015-11-17 22:20 +0100
[PATCH 1/7] misc: eeprom: 93xx46: Fix 16-bit read and write accesses. Cory Tusar <cory.tusar@pid1solutions.com> - 2015-11-17 05:20 +0100
[PATCH 3/7] misc: eeprom: 93xx46: Implement eeprom_93xx46 DT bindings. Cory Tusar <cory.tusar@pid1solutions.com> - 2015-11-17 05:20 +0100
| From | Cory Tusar <cory.tusar@pid1solutions.com> |
|---|---|
| Date | 2015-11-17 05:20 +0100 |
| Subject | [PATCH 0/7] Devicetree support for misc/eeprom/eeprom_93xx46. |
| Message-ID | <qvFUl-8sw-3@gated-at.bofh.it> |
This series of patches adds an initial set of devicetree bindings to the eeprom_93xx46 driver which mirror the configuration options previously available as a platform device. These bindings are then extended to include support for specific Atmel devices in this family and also to support GPIO-based selection of the device (e.g. for use with an SPI bus mux). Additionally, an address aliasing issue with 16-bit read and write accesses in the eeprom_93xx46 driver discovered during testing is fixed. Cory Tusar (7): misc: eeprom: 93xx46: Fix 16-bit read and write accesses. misc: eeprom: 93xx46: Add DT bindings to eeprom_93xx46 driver. misc: eeprom: 93xx46: Implement eeprom_93xx46 DT bindings. misc: eeprom: 93xx46: Add DT binding for Atmel AT93C46D devices. misc: eeprom: 93xx46: Add quirks to support Atmel AT93C46D device. misc: eeprom: 93xx46: Add DT binding for a GPIO 'select' line. misc: eeprom: 93xx46: Add support for a GPIO 'select' line. .../devicetree/bindings/misc/eeprom-93xx46.txt | 23 +++ drivers/misc/eeprom/eeprom_93xx46.c | 216 +++++++++++++++++---- include/linux/eeprom_93xx46.h | 7 + 3 files changed, 210 insertions(+), 36 deletions(-) create mode 100644 Documentation/devicetree/bindings/misc/eeprom-93xx46.txt -- 2.4.10 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Cory Tusar <cory.tusar@pid1solutions.com> |
|---|---|
| Date | 2015-11-17 05:20 +0100 |
| Subject | [PATCH 4/7] misc: eeprom: 93xx46: Add DT binding for Atmel AT93C46D devices. |
| Message-ID | <qvFUl-8sw-7@gated-at.bofh.it> |
| In reply to | #1270847 |
This commit adds a compatible string to the eeprom_93xx46 devicetree bindings in support of Atmel AT93C46D devices. Signed-off-by: Cory Tusar <cory.tusar@pid1solutions.com> --- Documentation/devicetree/bindings/misc/eeprom-93xx46.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt b/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt index ba493a8..34a0cc2 100644 --- a/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt +++ b/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt @@ -1,7 +1,7 @@ EEPROMs (SPI) compatible with Microchip Technology 93xx46 family. Required properties: -- compatible : "eeprom-93xx46" +- compatible : "eeprom-93xx46", "atmel,at93c46d" - data-size : number of data bits per word (either 8 or 16) Optional properties: -- 2.4.10 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Rob Herring <robh@kernel.org> |
|---|---|
| Date | 2015-11-17 22:00 +0100 |
| Subject | Re: [PATCH 4/7] misc: eeprom: 93xx46: Add DT binding for Atmel AT93C46D devices. |
| Message-ID | <qvVw6-1Ai-19@gated-at.bofh.it> |
| In reply to | #1270848 |
On Mon, Nov 16, 2015 at 11:16:33PM -0500, Cory Tusar wrote: > This commit adds a compatible string to the eeprom_93xx46 devicetree > bindings in support of Atmel AT93C46D devices. > > Signed-off-by: Cory Tusar <cory.tusar@pid1solutions.com> > --- > Documentation/devicetree/bindings/misc/eeprom-93xx46.txt | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt b/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt > index ba493a8..34a0cc2 100644 > --- a/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt > +++ b/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt > @@ -1,7 +1,7 @@ > EEPROMs (SPI) compatible with Microchip Technology 93xx46 family. > > Required properties: > -- compatible : "eeprom-93xx46" > +- compatible : "eeprom-93xx46", "atmel,at93c46d" This needs to be clear that it should be the opposite order. Something like this: compatible: One of the following: "atmel,at93c46d" Followed by "eeprom-93xx46" > - data-size : number of data bits per word (either 8 or 16) > > Optional properties: > -- > 2.4.10 > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Cory Tusar <cory.tusar@pid1solutions.com> |
|---|---|
| Date | 2015-11-17 22:20 +0100 |
| Subject | Re: [PATCH 4/7] misc: eeprom: 93xx46: Add DT binding for Atmel AT93C46D devices. |
| Message-ID | <qvVPs-1Xk-13@gated-at.bofh.it> |
| In reply to | #1271649 |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 11/17/2015 03:56 PM, Rob Herring wrote: > On Mon, Nov 16, 2015 at 11:16:33PM -0500, Cory Tusar wrote: >> This commit adds a compatible string to the eeprom_93xx46 devicetree >> bindings in support of Atmel AT93C46D devices. >> >> Signed-off-by: Cory Tusar <cory.tusar@pid1solutions.com> >> --- >> Documentation/devicetree/bindings/misc/eeprom-93xx46.txt | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt b/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt >> index ba493a8..34a0cc2 100644 >> --- a/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt >> +++ b/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt >> @@ -1,7 +1,7 @@ >> EEPROMs (SPI) compatible with Microchip Technology 93xx46 family. >> >> Required properties: >> -- compatible : "eeprom-93xx46" >> +- compatible : "eeprom-93xx46", "atmel,at93c46d" > > This needs to be clear that it should be the opposite order. Something > like this: > > compatible: One of the following: > "atmel,at93c46d" > Followed by "eeprom-93xx46" Will fix, thanks. >> - data-size : number of data bits per word (either 8 or 16) >> >> Optional properties: >> -- >> 2.4.10 >> - -- Cory Tusar Principal PID 1 Solutions, Inc. "There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies." --Sir Charles Anthony Richard Hoare -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAlZLmPIACgkQHT1tsfGwHJ9FrACeKfmCgXePFz/N3v9QMV7c4ASj SxcAnREBHu6lR5iAeyAtLpz8UCOOtDbn =EfAl -----END PGP SIGNATURE----- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Cory Tusar <cory.tusar@pid1solutions.com> |
|---|---|
| Date | 2015-11-17 05:20 +0100 |
| Subject | [PATCH 5/7] misc: eeprom: 93xx46: Add quirks to support Atmel AT93C46D device. |
| Message-ID | <qvFUm-8sw-13@gated-at.bofh.it> |
| In reply to | #1270847 |
Atmel devices in this family have some quirks not found in other similar
chips - they do not support a sequential read of the entire EEPROM
contents, and the control word sent at the start of each operation
varies in bit length.
This commit adds quirk support to the driver and modifies the read
implementation to support non-sequential reads for consistency with
other misc/eeprom drivers.
Tested on a custom Freescale VF610-based platform, with an AT93C46D
device attached via dspi2. The spi-gpio driver was used to allow the
necessary non-byte-sized transfers.
Signed-off-by: Cory Tusar <cory.tusar@pid1solutions.com>
---
drivers/misc/eeprom/eeprom_93xx46.c | 128 ++++++++++++++++++++++++++----------
include/linux/eeprom_93xx46.h | 6 ++
2 files changed, 98 insertions(+), 36 deletions(-)
diff --git a/drivers/misc/eeprom/eeprom_93xx46.c b/drivers/misc/eeprom/eeprom_93xx46.c
index 1f29d9a..0386b03 100644
--- a/drivers/misc/eeprom/eeprom_93xx46.c
+++ b/drivers/misc/eeprom/eeprom_93xx46.c
@@ -27,6 +27,15 @@
#define ADDR_ERAL 0x20
#define ADDR_EWEN 0x30
+struct eeprom_93xx46_devtype_data {
+ unsigned int quirks;
+};
+
+static const struct eeprom_93xx46_devtype_data atmel_at93c46d_data = {
+ .quirks = EEPROM_93XX46_QUIRK_SINGLE_WORD_READ |
+ EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH,
+};
+
struct eeprom_93xx46_dev {
struct spi_device *spi;
struct eeprom_93xx46_platform_data *pdata;
@@ -35,6 +44,16 @@ struct eeprom_93xx46_dev {
int addrlen;
};
+static inline bool has_quirk_single_word_read(struct eeprom_93xx46_dev *edev)
+{
+ return !!(edev->pdata->quirks & EEPROM_93XX46_QUIRK_SINGLE_WORD_READ);
+}
+
+static inline bool has_quirk_instruction_length(struct eeprom_93xx46_dev *edev)
+{
+ return !!(edev->pdata->quirks & EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH);
+}
+
static ssize_t
eeprom_93xx46_bin_read(struct file *filp, struct kobject *kobj,
struct bin_attribute *bin_attr,
@@ -42,58 +61,73 @@ eeprom_93xx46_bin_read(struct file *filp, struct kobject *kobj,
{
struct eeprom_93xx46_dev *edev;
struct device *dev;
- struct spi_message m;
- struct spi_transfer t[2];
- int bits, ret;
- u16 cmd_addr;
+ ssize_t ret = 0;
dev = container_of(kobj, struct device, kobj);
edev = dev_get_drvdata(dev);
- cmd_addr = OP_READ << edev->addrlen;
+ mutex_lock(&edev->lock);
- if (edev->addrlen == 7) {
- cmd_addr |= off & 0x7f;
- bits = 10;
- } else {
- cmd_addr |= (off >> 1) & 0x3f;
- bits = 9;
- }
+ if (edev->pdata->prepare)
+ edev->pdata->prepare(edev);
- dev_dbg(&edev->spi->dev, "read cmd 0x%x, %d Hz\n",
- cmd_addr, edev->spi->max_speed_hz);
+ while (count) {
+ struct spi_message m;
+ struct spi_transfer t[2] = { { 0 } };
+ u16 cmd_addr = OP_READ << edev->addrlen;
+ size_t nbytes = count;
+ int bits;
+ int err;
+
+ if (edev->addrlen == 7) {
+ cmd_addr |= off & 0x7f;
+ bits = 10;
+ if (has_quirk_single_word_read(edev))
+ nbytes = 1;
+ } else {
+ cmd_addr |= (off >> 1) & 0x3f;
+ bits = 9;
+ if (has_quirk_single_word_read(edev))
+ nbytes = 2;
+ }
- spi_message_init(&m);
- memset(t, 0, sizeof(t));
+ dev_dbg(&edev->spi->dev, "read cmd 0x%x, %d Hz\n",
+ cmd_addr, edev->spi->max_speed_hz);
- t[0].tx_buf = (char *)&cmd_addr;
- t[0].len = 2;
- t[0].bits_per_word = bits;
- spi_message_add_tail(&t[0], &m);
+ spi_message_init(&m);
- t[1].rx_buf = buf;
- t[1].len = count;
- t[1].bits_per_word = 8;
- spi_message_add_tail(&t[1], &m);
+ t[0].tx_buf = (char *)&cmd_addr;
+ t[0].len = 2;
+ t[0].bits_per_word = bits;
+ spi_message_add_tail(&t[0], &m);
- mutex_lock(&edev->lock);
+ t[1].rx_buf = buf;
+ t[1].len = count;
+ t[1].bits_per_word = 8;
+ spi_message_add_tail(&t[1], &m);
- if (edev->pdata->prepare)
- edev->pdata->prepare(edev);
+ err = spi_sync(edev->spi, &m);
+ /* have to wait at least Tcsl ns */
+ ndelay(250);
- ret = spi_sync(edev->spi, &m);
- /* have to wait at least Tcsl ns */
- ndelay(250);
- if (ret) {
- dev_err(&edev->spi->dev, "read %zu bytes at %d: err. %d\n",
- count, (int)off, ret);
+ if (err) {
+ dev_err(&edev->spi->dev, "read %zu bytes at %d: err. %d\n",
+ nbytes, (int)off, err);
+ ret = err;
+ break;
+ }
+
+ buf += nbytes;
+ off += nbytes;
+ count -= nbytes;
+ ret += nbytes;
}
if (edev->pdata->finish)
edev->pdata->finish(edev);
mutex_unlock(&edev->lock);
- return ret ? : count;
+ return ret;
}
static int eeprom_93xx46_ew(struct eeprom_93xx46_dev *edev, int is_on)
@@ -112,7 +146,13 @@ static int eeprom_93xx46_ew(struct eeprom_93xx46_dev *edev, int is_on)
bits = 9;
}
- dev_dbg(&edev->spi->dev, "ew cmd 0x%04x\n", cmd_addr);
+ if (has_quirk_instruction_length(edev)) {
+ cmd_addr <<= 2;
+ bits += 2;
+ }
+
+ dev_dbg(&edev->spi->dev, "ew%s cmd 0x%04x, %d bits\n",
+ is_on ? "en" : "ds", cmd_addr, bits);
spi_message_init(&m);
memset(&t, 0, sizeof(t));
@@ -247,6 +287,13 @@ static int eeprom_93xx46_eral(struct eeprom_93xx46_dev *edev)
bits = 9;
}
+ if (has_quirk_instruction_length(edev)) {
+ cmd_addr <<= 2;
+ bits += 2;
+ }
+
+ dev_dbg(&edev->spi->dev, "eral cmd 0x%04x, %d bits\n", cmd_addr, bits);
+
spi_message_init(&m);
memset(&t, 0, sizeof(t));
@@ -299,18 +346,21 @@ static DEVICE_ATTR(erase, S_IWUSR, NULL, eeprom_93xx46_store_erase);
#ifdef CONFIG_OF
static const struct of_device_id eeprom_93xx46_of_table[] = {
{ .compatible = "eeprom-93xx46", },
+ { .compatible = "atmel,at93c46d", .data = &atmel_at93c46d_data, },
{}
};
MODULE_DEVICE_TABLE(of, eeprom_93xx46_of_table);
static int eeprom_93xx46_probe_dt(struct spi_device *spi)
{
+ const struct of_device_id *of_id =
+ of_match_device(eeprom_93xx46_of_table, &spi->dev);
struct device_node *np = spi->dev.of_node;
struct eeprom_93xx46_platform_data *pd;
u32 tmp;
int ret;
- if (!of_match_device(eeprom_93xx46_of_table, &spi->dev))
+ if (!of_id)
return 0;
pd = devm_kzalloc(&spi->dev, sizeof(*pd), GFP_KERNEL);
@@ -335,6 +385,12 @@ static int eeprom_93xx46_probe_dt(struct spi_device *spi)
if (of_property_read_bool(np, "read-only"))
pd->flags |= EE_READONLY;
+ if (of_id->data) {
+ const struct eeprom_93xx46_devtype_data *data = of_id->data;
+
+ pd->quirks = data->quirks;
+ }
+
spi->dev.platform_data = pd;
return 1;
diff --git a/include/linux/eeprom_93xx46.h b/include/linux/eeprom_93xx46.h
index 0679181..92fa4c3 100644
--- a/include/linux/eeprom_93xx46.h
+++ b/include/linux/eeprom_93xx46.h
@@ -9,6 +9,12 @@ struct eeprom_93xx46_platform_data {
#define EE_ADDR16 0x02 /* 16 bit addr. cfg */
#define EE_READONLY 0x08 /* forbid writing */
+ unsigned int quirks;
+/* Single word read transfers only; no sequential read. */
+#define EEPROM_93XX46_QUIRK_SINGLE_WORD_READ (1 << 0)
+/* Instructions such as EWEN are (addrlen + 2) in length. */
+#define EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH (1 << 1)
+
/*
* optional hooks to control additional logic
* before and after spi transfer.
--
2.4.10
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Cory Tusar <cory.tusar@pid1solutions.com> |
|---|---|
| Date | 2015-11-17 05:20 +0100 |
| Subject | [PATCH 6/7] misc: eeprom: 93xx46: Add DT binding for a GPIO 'select' line. |
| Message-ID | <qvFUm-8sw-15@gated-at.bofh.it> |
| In reply to | #1270847 |
This commit documents an additional devicetree binding in the eeprom_93x46 driver allowing a GPIO line to function as a 'select' or 'enable' signal prior to accessing the EEPROM. Signed-off-by: Cory Tusar <cory.tusar@pid1solutions.com> --- Documentation/devicetree/bindings/misc/eeprom-93xx46.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt b/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt index 34a0cc2..75b16f4 100644 --- a/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt +++ b/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt @@ -6,6 +6,8 @@ Required properties: Optional properties: - read-only : parameter-less property which disables writes to the EEPROM +- select-gpio : if present, specifies the GPIO that will be asserted prior to + each access to the EEPROM (e.g. for SPI bus multiplexing) Property rules described in Documentation/devicetree/bindings/spi/spi-bus.txt apply. In particular, "reg" and "spi-max-frequency" properties must be given. @@ -17,4 +19,5 @@ Example: spi-max-frequency = <1000000>; spi-cs-high; data-size = <8>; + select-gpio = <&gpio4 4 GPIO_ACTIVE_HIGH>; }; -- 2.4.10 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Rob Herring <robh@kernel.org> |
|---|---|
| Date | 2015-11-17 22:00 +0100 |
| Subject | Re: [PATCH 6/7] misc: eeprom: 93xx46: Add DT binding for a GPIO 'select' line. |
| Message-ID | <qvVw6-1Ai-13@gated-at.bofh.it> |
| In reply to | #1270852 |
On Mon, Nov 16, 2015 at 11:16:35PM -0500, Cory Tusar wrote: > This commit documents an additional devicetree binding in the > eeprom_93x46 driver allowing a GPIO line to function as a 'select' > or 'enable' signal prior to accessing the EEPROM. You can just fold all the DT binding patches into 1. They don't have to match up to driver changes. > > Signed-off-by: Cory Tusar <cory.tusar@pid1solutions.com> > --- > Documentation/devicetree/bindings/misc/eeprom-93xx46.txt | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt b/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt > index 34a0cc2..75b16f4 100644 > --- a/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt > +++ b/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt > @@ -6,6 +6,8 @@ Required properties: > > Optional properties: > - read-only : parameter-less property which disables writes to the EEPROM > +- select-gpio : if present, specifies the GPIO that will be asserted prior to > + each access to the EEPROM (e.g. for SPI bus multiplexing) This should be "select-gpios". > > Property rules described in Documentation/devicetree/bindings/spi/spi-bus.txt > apply. In particular, "reg" and "spi-max-frequency" properties must be given. > @@ -17,4 +19,5 @@ Example: > spi-max-frequency = <1000000>; > spi-cs-high; > data-size = <8>; > + select-gpio = <&gpio4 4 GPIO_ACTIVE_HIGH>; > }; > -- > 2.4.10 > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Cory Tusar <cory.tusar@pid1solutions.com> |
|---|---|
| Date | 2015-11-17 22:20 +0100 |
| Subject | Re: [PATCH 6/7] misc: eeprom: 93xx46: Add DT binding for a GPIO 'select' line. |
| Message-ID | <qvVPs-1Xk-17@gated-at.bofh.it> |
| In reply to | #1271650 |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 11/17/2015 03:59 PM, Rob Herring wrote: > On Mon, Nov 16, 2015 at 11:16:35PM -0500, Cory Tusar wrote: >> This commit documents an additional devicetree binding in the >> eeprom_93x46 driver allowing a GPIO line to function as a 'select' >> or 'enable' signal prior to accessing the EEPROM. > > You can just fold all the DT binding patches into 1. They don't have to > match up to driver changes. Will do. >> >> Signed-off-by: Cory Tusar <cory.tusar@pid1solutions.com> >> --- >> Documentation/devicetree/bindings/misc/eeprom-93xx46.txt | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt b/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt >> index 34a0cc2..75b16f4 100644 >> --- a/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt >> +++ b/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt >> @@ -6,6 +6,8 @@ Required properties: >> >> Optional properties: >> - read-only : parameter-less property which disables writes to the EEPROM >> +- select-gpio : if present, specifies the GPIO that will be asserted prior to >> + each access to the EEPROM (e.g. for SPI bus multiplexing) > > This should be "select-gpios". Will fix, thanks. >> >> Property rules described in Documentation/devicetree/bindings/spi/spi-bus.txt >> apply. In particular, "reg" and "spi-max-frequency" properties must be given. >> @@ -17,4 +19,5 @@ Example: >> spi-max-frequency = <1000000>; >> spi-cs-high; >> data-size = <8>; >> + select-gpio = <&gpio4 4 GPIO_ACTIVE_HIGH>; >> }; >> -- >> 2.4.10 >> - -- Cory Tusar Principal PID 1 Solutions, Inc. "There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies." --Sir Charles Anthony Richard Hoare -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAlZLmdEACgkQHT1tsfGwHJ+2xACdFuo21bKIe5y4tYHw63b5OA/s x20AnRKVla1svFEX15dNvrCwzgCBZ7cl =lXQy -----END PGP SIGNATURE----- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Cory Tusar <cory.tusar@pid1solutions.com> |
|---|---|
| Date | 2015-11-17 05:20 +0100 |
| Subject | [PATCH 2/7] misc: eeprom: 93xx46: Add DT bindings to eeprom_93xx46 driver. |
| Message-ID | <qvFUm-8sw-17@gated-at.bofh.it> |
| In reply to | #1270847 |
This commit documents bindings to be added to the eeprom_93xx46 driver
which allow device word size and read-only attributes to be specified
via devicetree.
Currently the only supported device is a generic "eeprom-93xx46", which
mirrors the configuration options previously available as a platform
device.
Signed-off-by: Cory Tusar <cory.tusar@pid1solutions.com>
---
.../devicetree/bindings/misc/eeprom-93xx46.txt | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt b/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt
new file mode 100644
index 0000000..ba493a8
--- /dev/null
+++ b/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt
@@ -0,0 +1,20 @@
+EEPROMs (SPI) compatible with Microchip Technology 93xx46 family.
+
+Required properties:
+- compatible : "eeprom-93xx46"
+- data-size : number of data bits per word (either 8 or 16)
+
+Optional properties:
+- read-only : parameter-less property which disables writes to the EEPROM
+
+Property rules described in Documentation/devicetree/bindings/spi/spi-bus.txt
+apply. In particular, "reg" and "spi-max-frequency" properties must be given.
+
+Example:
+ 93c46c@0 {
+ compatible = "eeprom-93xx46";
+ reg = <0>;
+ spi-max-frequency = <1000000>;
+ spi-cs-high;
+ data-size = <8>;
+ };
--
2.4.10
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Rob Herring <robh@kernel.org> |
|---|---|
| Date | 2015-11-17 22:00 +0100 |
| Subject | Re: [PATCH 2/7] misc: eeprom: 93xx46: Add DT bindings to eeprom_93xx46 driver. |
| Message-ID | <qvVw6-1Ai-11@gated-at.bofh.it> |
| In reply to | #1270853 |
On Mon, Nov 16, 2015 at 11:16:31PM -0500, Cory Tusar wrote:
> This commit documents bindings to be added to the eeprom_93xx46 driver
> which allow device word size and read-only attributes to be specified
> via devicetree.
>
> Currently the only supported device is a generic "eeprom-93xx46", which
> mirrors the configuration options previously available as a platform
> device.
>
> Signed-off-by: Cory Tusar <cory.tusar@pid1solutions.com>
> ---
> .../devicetree/bindings/misc/eeprom-93xx46.txt | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt b/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt
> new file mode 100644
> index 0000000..ba493a8
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt
> @@ -0,0 +1,20 @@
> +EEPROMs (SPI) compatible with Microchip Technology 93xx46 family.
> +
> +Required properties:
> +- compatible : "eeprom-93xx46"
This should also have a compatible with the actual manufacturer.
> +- data-size : number of data bits per word (either 8 or 16)
> +
> +Optional properties:
> +- read-only : parameter-less property which disables writes to the EEPROM
> +
> +Property rules described in Documentation/devicetree/bindings/spi/spi-bus.txt
> +apply. In particular, "reg" and "spi-max-frequency" properties must be given.
> +
> +Example:
> + 93c46c@0 {
> + compatible = "eeprom-93xx46";
> + reg = <0>;
> + spi-max-frequency = <1000000>;
> + spi-cs-high;
> + data-size = <8>;
> + };
> --
> 2.4.10
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Cory Tusar <cory.tusar@pid1solutions.com> |
|---|---|
| Date | 2015-11-17 22:20 +0100 |
| Subject | Re: [PATCH 2/7] misc: eeprom: 93xx46: Add DT bindings to eeprom_93xx46 driver. |
| Message-ID | <qvVPs-1Xk-5@gated-at.bofh.it> |
| In reply to | #1271648 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 11/17/2015 03:53 PM, Rob Herring wrote:
> On Mon, Nov 16, 2015 at 11:16:31PM -0500, Cory Tusar wrote:
>> This commit documents bindings to be added to the eeprom_93xx46 driver
>> which allow device word size and read-only attributes to be specified
>> via devicetree.
>>
>> Currently the only supported device is a generic "eeprom-93xx46", which
>> mirrors the configuration options previously available as a platform
>> device.
>>
>> Signed-off-by: Cory Tusar <cory.tusar@pid1solutions.com>
>> ---
>> .../devicetree/bindings/misc/eeprom-93xx46.txt | 20 ++++++++++++++++++++
>> 1 file changed, 20 insertions(+)
>>
>> diff --git a/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt b/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt
>> new file mode 100644
>> index 0000000..ba493a8
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/misc/eeprom-93xx46.txt
>> @@ -0,0 +1,20 @@
>> +EEPROMs (SPI) compatible with Microchip Technology 93xx46 family.
>> +
>> +Required properties:
>> +- compatible : "eeprom-93xx46"
>
> This should also have a compatible with the actual manufacturer.
Above and beyond the one that's added later for the specific Atmel part
I've tested with?
>> +- data-size : number of data bits per word (either 8 or 16)
>> +
>> +Optional properties:
>> +- read-only : parameter-less property which disables writes to the EEPROM
>> +
>> +Property rules described in Documentation/devicetree/bindings/spi/spi-bus.txt
>> +apply. In particular, "reg" and "spi-max-frequency" properties must be given.
>> +
>> +Example:
>> + 93c46c@0 {
>> + compatible = "eeprom-93xx46";
>> + reg = <0>;
>> + spi-max-frequency = <1000000>;
>> + spi-cs-high;
>> + data-size = <8>;
>> + };
>> --
>> 2.4.10
>>
- --
Cory Tusar
Principal
PID 1 Solutions, Inc.
"There are two ways of constructing a software design. One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies." --Sir Charles Anthony Richard Hoare
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iEYEARECAAYFAlZLmLgACgkQHT1tsfGwHJ/HTgCgjgtEntrpZNlGyHMjw3EPuOLT
ZJ4AnRQPgOjG5IouJIXURjlkNGor9Npl
=8pqx
-----END PGP SIGNATURE-----
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Cory Tusar <cory.tusar@pid1solutions.com> |
|---|---|
| Date | 2015-11-17 05:20 +0100 |
| Subject | [PATCH 1/7] misc: eeprom: 93xx46: Fix 16-bit read and write accesses. |
| Message-ID | <qvFUm-8sw-23@gated-at.bofh.it> |
| In reply to | #1270847 |
Compatible at93xx46 devices from both Microchip and Atmel expect a
word-based address, regardless of whether the device is strapped for 8-
or 16-bit operation. However, the offset parameter passed in when
reading or writing at a specific location is always specified in terms
of bytes.
This commit fixes 16-bit read and write accesses by shifting the offset
parameter to account for this difference between a byte offset and a
word-based address.
Signed-off-by: Cory Tusar <cory.tusar@pid1solutions.com>
---
drivers/misc/eeprom/eeprom_93xx46.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/eeprom/eeprom_93xx46.c b/drivers/misc/eeprom/eeprom_93xx46.c
index ff63f05..e1bf0a5 100644
--- a/drivers/misc/eeprom/eeprom_93xx46.c
+++ b/drivers/misc/eeprom/eeprom_93xx46.c
@@ -54,7 +54,7 @@ eeprom_93xx46_bin_read(struct file *filp, struct kobject *kobj,
cmd_addr |= off & 0x7f;
bits = 10;
} else {
- cmd_addr |= off & 0x3f;
+ cmd_addr |= (off >> 1) & 0x3f;
bits = 9;
}
@@ -155,7 +155,7 @@ eeprom_93xx46_write_word(struct eeprom_93xx46_dev *edev,
bits = 10;
data_len = 1;
} else {
- cmd_addr |= off & 0x3f;
+ cmd_addr |= (off >> 1) & 0x3f;
bits = 9;
data_len = 2;
}
--
2.4.10
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Cory Tusar <cory.tusar@pid1solutions.com> |
|---|---|
| Date | 2015-11-17 05:20 +0100 |
| Subject | [PATCH 3/7] misc: eeprom: 93xx46: Implement eeprom_93xx46 DT bindings. |
| Message-ID | <qvFUm-8sw-19@gated-at.bofh.it> |
| In reply to | #1270847 |
This commit implements bindings in the eeprom_93xx46 driver allowing
device word size and read-only attributes to be specified via
devicetree.
Signed-off-by: Cory Tusar <cory.tusar@pid1solutions.com>
---
drivers/misc/eeprom/eeprom_93xx46.c | 62 +++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/drivers/misc/eeprom/eeprom_93xx46.c b/drivers/misc/eeprom/eeprom_93xx46.c
index e1bf0a5..1f29d9a 100644
--- a/drivers/misc/eeprom/eeprom_93xx46.c
+++ b/drivers/misc/eeprom/eeprom_93xx46.c
@@ -13,6 +13,8 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mutex.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
#include <linux/slab.h>
#include <linux/spi/spi.h>
#include <linux/sysfs.h>
@@ -294,12 +296,71 @@ static ssize_t eeprom_93xx46_store_erase(struct device *dev,
}
static DEVICE_ATTR(erase, S_IWUSR, NULL, eeprom_93xx46_store_erase);
+#ifdef CONFIG_OF
+static const struct of_device_id eeprom_93xx46_of_table[] = {
+ { .compatible = "eeprom-93xx46", },
+ {}
+};
+MODULE_DEVICE_TABLE(of, eeprom_93xx46_of_table);
+
+static int eeprom_93xx46_probe_dt(struct spi_device *spi)
+{
+ struct device_node *np = spi->dev.of_node;
+ struct eeprom_93xx46_platform_data *pd;
+ u32 tmp;
+ int ret;
+
+ if (!of_match_device(eeprom_93xx46_of_table, &spi->dev))
+ return 0;
+
+ pd = devm_kzalloc(&spi->dev, sizeof(*pd), GFP_KERNEL);
+ if (!pd)
+ return -ENOMEM;
+
+ ret = of_property_read_u32(np, "data-size", &tmp);
+ if (ret < 0) {
+ dev_err(&spi->dev, "data-size property not found\n");
+ goto error_free;
+ }
+
+ if (tmp == 8) {
+ pd->flags |= EE_ADDR8;
+ } else if (tmp == 16) {
+ pd->flags |= EE_ADDR16;
+ } else {
+ dev_err(&spi->dev, "invalid data-size (%d)\n", tmp);
+ goto error_free;
+ }
+
+ if (of_property_read_bool(np, "read-only"))
+ pd->flags |= EE_READONLY;
+
+ spi->dev.platform_data = pd;
+
+ return 1;
+
+error_free:
+ devm_kfree(&spi->dev, pd);
+ return ret;
+}
+
+#else
+static inline int eeprom_93xx46_probe_dt(struct spi_device *spi)
+{
+ return 0;
+}
+#endif
+
static int eeprom_93xx46_probe(struct spi_device *spi)
{
struct eeprom_93xx46_platform_data *pd;
struct eeprom_93xx46_dev *edev;
int err;
+ err = eeprom_93xx46_probe_dt(spi);
+ if (err < 0)
+ return err;
+
pd = spi->dev.platform_data;
if (!pd) {
dev_err(&spi->dev, "missing platform data\n");
@@ -370,6 +431,7 @@ static int eeprom_93xx46_remove(struct spi_device *spi)
static struct spi_driver eeprom_93xx46_driver = {
.driver = {
.name = "93xx46",
+ .of_match_table = eeprom_93xx46_of_table,
},
.probe = eeprom_93xx46_probe,
.remove = eeprom_93xx46_remove,
--
2.4.10
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web