* [patch 1/9] eeprom_93cx6: Add data direction control. [not found] <20091207121727.016092171@fluff.org.uk> @ 2009-12-07 12:17 ` Ben Dooks 2009-12-07 12:21 ` Jean Delvare 2009-12-07 12:17 ` [patch 2/9] eeprom_93cx6: Add write support Ben Dooks 1 sibling, 1 reply; 5+ messages in thread From: Ben Dooks @ 2009-12-07 12:17 UTC (permalink / raw) To: netdev Cc: linux, doong.ping, tristram.ha, Wolfram Sang, Jean Delvare, Linux Kernel [-- Attachment #1: 93c-eeprom-add-direction.patch --] [-- Type: text/plain, Size: 2337 bytes --] Some devices need to know if the data is to be output or read, so add a data direction into the eeprom structure to tell the driver whether the data line should be driven. The user in this case is the Micrel KS8851 which has a direction control for the EEPROM data line and thus needs to know whether to drive it (writing) or to tristate it for receiving. Signed-off-by: Ben Dooks <ben@simtec.co.uk> Cc: Wolfram Sang <w.sang@pengutronix.de> Cc: Jean Delvare <khali@linux-fr.org> Cc: Linux Kernel <linux-kernel@vger.kernel.org> -- drivers/misc/eeprom/eeprom_93cx6.c | 3 +++ include/linux/eeprom_93cx6.h | 2 ++ 2 files changed, 5 insertions(+) Index: b/drivers/misc/eeprom/eeprom_93cx6.c =================================================================== --- a/drivers/misc/eeprom/eeprom_93cx6.c 2009-10-06 15:35:38.000000000 +0100 +++ b/drivers/misc/eeprom/eeprom_93cx6.c 2009-10-06 15:51:18.000000000 +0100 @@ -70,6 +70,7 @@ static void eeprom_93cx6_startup(struct eeprom->reg_data_out = 0; eeprom->reg_data_clock = 0; eeprom->reg_chip_select = 1; + eeprom->drive_data = 1; eeprom->register_write(eeprom); /* @@ -108,6 +109,7 @@ static void eeprom_93cx6_write_bits(stru */ eeprom->reg_data_in = 0; eeprom->reg_data_out = 0; + eeprom->drive_data = 1; /* * Start writing all bits. @@ -147,6 +149,7 @@ static void eeprom_93cx6_read_bits(struc */ eeprom->reg_data_in = 0; eeprom->reg_data_out = 0; + eeprom->drive_data = 0; /* * Start reading all bits. Index: b/include/linux/eeprom_93cx6.h =================================================================== --- a/include/linux/eeprom_93cx6.h 2009-10-06 15:35:38.000000000 +0100 +++ b/include/linux/eeprom_93cx6.h 2009-10-06 15:51:18.000000000 +0100 @@ -45,6 +45,7 @@ * @register_write(struct eeprom_93cx6 *eeprom): handler to * write to the eeprom register by using all reg_* fields. * @width: eeprom width, should be one of the PCI_EEPROM_WIDTH_* defines + * @drive_data: Set if we're driving the data line. * @reg_data_in: register field to indicate data input * @reg_data_out: register field to indicate data output * @reg_data_clock: register field to set the data clock @@ -61,6 +62,7 @@ struct eeprom_93cx6 { int width; + char drive_data; char reg_data_in; char reg_data_out; char reg_data_clock; ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch 1/9] eeprom_93cx6: Add data direction control. 2009-12-07 12:17 ` [patch 1/9] eeprom_93cx6: Add data direction control Ben Dooks @ 2009-12-07 12:21 ` Jean Delvare 2009-12-07 12:24 ` Ben Dooks 0 siblings, 1 reply; 5+ messages in thread From: Jean Delvare @ 2009-12-07 12:21 UTC (permalink / raw) To: Ben Dooks Cc: netdev, linux, doong.ping, tristram.ha, Wolfram Sang, Linux Kernel On Mon, 07 Dec 2009 12:17:28 +0000, Ben Dooks wrote: > Some devices need to know if the data is to be output or read, so add a > data direction into the eeprom structure to tell the driver whether the > data line should be driven. > > The user in this case is the Micrel KS8851 which has a direction > control for the EEPROM data line and thus needs to know whether > to drive it (writing) or to tristate it for receiving. > > Signed-off-by: Ben Dooks <ben@simtec.co.uk> > Cc: Wolfram Sang <w.sang@pengutronix.de> > Cc: Jean Delvare <khali@linux-fr.org> > Cc: Linux Kernel <linux-kernel@vger.kernel.org> FYI, I will not be reviewing this patch nor any other patch to the eeprom_93cx6 driver. I have no clue what these devices are, no access to any and no interest in them either. -- Jean Delvare ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [patch 1/9] eeprom_93cx6: Add data direction control. 2009-12-07 12:21 ` Jean Delvare @ 2009-12-07 12:24 ` Ben Dooks 0 siblings, 0 replies; 5+ messages in thread From: Ben Dooks @ 2009-12-07 12:24 UTC (permalink / raw) To: Jean Delvare Cc: netdev, Linux Kernel, Wolfram Sang, doong.ping, tristram.ha, linux Jean Delvare wrote: > On Mon, 07 Dec 2009 12:17:28 +0000, Ben Dooks wrote: >> Some devices need to know if the data is to be output or read, so add a >> data direction into the eeprom structure to tell the driver whether the >> data line should be driven. >> >> The user in this case is the Micrel KS8851 which has a direction >> control for the EEPROM data line and thus needs to know whether >> to drive it (writing) or to tristate it for receiving. >> >> Signed-off-by: Ben Dooks <ben@simtec.co.uk> >> Cc: Wolfram Sang <w.sang@pengutronix.de> >> Cc: Jean Delvare <khali@linux-fr.org> >> Cc: Linux Kernel <linux-kernel@vger.kernel.org> > > FYI, I will not be reviewing this patch nor any other patch to the > eeprom_93cx6 driver. I have no clue what these devices are, no access > to any and no interest in them either. Ok, scripts/get_maintainer.pl came up with yourself, Wolfram and linux-kernel as the people to send this to. -- Ben Dooks, Design & Software Engineer, Simtec Electronics http://www.simtec.co.uk/ ^ permalink raw reply [flat|nested] 5+ messages in thread
* [patch 2/9] eeprom_93cx6: Add write support [not found] <20091207121727.016092171@fluff.org.uk> 2009-12-07 12:17 ` [patch 1/9] eeprom_93cx6: Add data direction control Ben Dooks @ 2009-12-07 12:17 ` Ben Dooks 1 sibling, 0 replies; 5+ messages in thread From: Ben Dooks @ 2009-12-07 12:17 UTC (permalink / raw) To: netdev Cc: linux, doong.ping, tristram.ha, Wolfram Sang, Jean Delvare, Linux Kernel [-- Attachment #1: 93c-eeprom-add-write.patch --] [-- Type: text/plain, Size: 3857 bytes --] Add support for writing data to EEPROM. Signed-off-by: Ben Dooks <ben@simtec.co.uk> Cc: Wolfram Sang <w.sang@pengutronix.de> Cc: Jean Delvare <khali@linux-fr.org> Cc: Linux Kernel <linux-kernel@vger.kernel.org> --- drivers/misc/eeprom/eeprom_93cx6.c | 86 +++++++++++++++++++++++++++++++++++++ include/linux/eeprom_93cx6.h | 7 +++ 2 files changed, 93 insertions(+) Index: b/drivers/misc/eeprom/eeprom_93cx6.c =================================================================== --- a/drivers/misc/eeprom/eeprom_93cx6.c 2009-10-06 15:51:18.000000000 +0100 +++ b/drivers/misc/eeprom/eeprom_93cx6.c 2009-10-06 15:54:36.000000000 +0100 @@ -241,3 +241,89 @@ void eeprom_93cx6_multiread(struct eepro } EXPORT_SYMBOL_GPL(eeprom_93cx6_multiread); + +/** + * eeprom_93cx6_wren - set the write enable state + * @eeprom: Pointer to eeprom structure + * @enable: true to enable writes, otherwise disable writes + * + * Set the EEPROM write enable state to either allow or deny + * writes depending on the @enable value. + */ +void eeprom_93cx6_wren(struct eeprom_93cx6 *eeprom, bool enable) +{ + u16 command; + + /* start the command */ + eeprom_93cx6_startup(eeprom); + + /* create command to enable/disable */ + + command = enable ? PCI_EEPROM_EWEN_OPCODE : PCI_EEPROM_EWDS_OPCODE; + command <<= (eeprom->width - 2); + + eeprom_93cx6_write_bits(eeprom, command, + PCI_EEPROM_WIDTH_OPCODE + eeprom->width); + + eeprom_93cx6_cleanup(eeprom); +} +EXPORT_SYMBOL_GPL(eeprom_93cx6_wren); + +/** + * eeprom_93cx6_write - write data to the EEPROM + * @eeprom: Pointer to eeprom structure + * @addr: Address to write data to. + * @data: The data to write to address @addr. + * + * Write the @data to the specified @addr in the EEPROM and + * waiting for the device to finish writing. + * + * Note, since we do not expect large number of write operations + * we use msleep() to delay in between parts of the operation to + * avoid using excessive amounts of CPU time busy waiting. + */ +void eeprom_93cx6_write(struct eeprom_93cx6 *eeprom, u8 addr, u16 data) +{ + int timeout = 100; + u16 command; + + /* start the command */ + eeprom_93cx6_startup(eeprom); + + command = PCI_EEPROM_WRITE_OPCODE << eeprom->width; + command |= addr; + + /* send write command */ + eeprom_93cx6_write_bits(eeprom, command, + PCI_EEPROM_WIDTH_OPCODE + eeprom->width); + + /* send data */ + eeprom_93cx6_write_bits(eeprom, data, 16); + + /* get ready to check for busy */ + eeprom->drive_data = 0; + eeprom->reg_chip_select = 1; + eeprom->register_write(eeprom); + + /* wait at-least 250ns to get DO to be the busy signal */ + msleep(1); + + /* wait for DO to go high to signify finish */ + + while (true) { + eeprom->register_read(eeprom); + + if (eeprom->reg_data_out) + break; + + msleep(1); + + if (--timeout <= 0) { + printk(KERN_ERR "%s: timeout\n", __func__); + break; + } + } + + eeprom_93cx6_cleanup(eeprom); +} +EXPORT_SYMBOL_GPL(eeprom_93cx6_write); Index: b/include/linux/eeprom_93cx6.h =================================================================== --- a/include/linux/eeprom_93cx6.h 2009-10-06 15:51:18.000000000 +0100 +++ b/include/linux/eeprom_93cx6.h 2009-10-06 15:53:16.000000000 +0100 @@ -32,6 +32,7 @@ #define PCI_EEPROM_WIDTH_93C66 8 #define PCI_EEPROM_WIDTH_OPCODE 3 #define PCI_EEPROM_WRITE_OPCODE 0x05 +#define PCI_EEPROM_ERASE_OPCODE 0x07 #define PCI_EEPROM_READ_OPCODE 0x06 #define PCI_EEPROM_EWDS_OPCODE 0x10 #define PCI_EEPROM_EWEN_OPCODE 0x13 @@ -73,3 +74,9 @@ extern void eeprom_93cx6_read(struct eep const u8 word, u16 *data); extern void eeprom_93cx6_multiread(struct eeprom_93cx6 *eeprom, const u8 word, __le16 *data, const u16 words); + +extern void eeprom_93cx6_wren(struct eeprom_93cx6 *eeprom, bool enable); + +extern void eeprom_93cx6_write(struct eeprom_93cx6 *eeprom, + u8 addr, u16 data); + ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <20091207121501.819539008@fluff.org.uk>]
* [patch 2/9] eeprom_93cx6: Add write support [not found] <20091207121501.819539008@fluff.org.uk> @ 2009-12-07 12:15 ` ben 0 siblings, 0 replies; 5+ messages in thread From: ben @ 2009-12-07 12:15 UTC (permalink / raw) To: netdev Cc: linux, doong.ping, tristram.ha, Wolfram Sang, Jean Delvare, Linux Kernel [-- Attachment #1: 93c-eeprom-add-write.patch --] [-- Type: text/plain, Size: 3857 bytes --] Add support for writing data to EEPROM. Signed-off-by: Ben Dooks <ben@simtec.co.uk> Cc: Wolfram Sang <w.sang@pengutronix.de> Cc: Jean Delvare <khali@linux-fr.org> Cc: Linux Kernel <linux-kernel@vger.kernel.org> --- drivers/misc/eeprom/eeprom_93cx6.c | 86 +++++++++++++++++++++++++++++++++++++ include/linux/eeprom_93cx6.h | 7 +++ 2 files changed, 93 insertions(+) Index: b/drivers/misc/eeprom/eeprom_93cx6.c =================================================================== --- a/drivers/misc/eeprom/eeprom_93cx6.c 2009-10-06 15:51:18.000000000 +0100 +++ b/drivers/misc/eeprom/eeprom_93cx6.c 2009-10-06 15:54:36.000000000 +0100 @@ -241,3 +241,89 @@ void eeprom_93cx6_multiread(struct eepro } EXPORT_SYMBOL_GPL(eeprom_93cx6_multiread); + +/** + * eeprom_93cx6_wren - set the write enable state + * @eeprom: Pointer to eeprom structure + * @enable: true to enable writes, otherwise disable writes + * + * Set the EEPROM write enable state to either allow or deny + * writes depending on the @enable value. + */ +void eeprom_93cx6_wren(struct eeprom_93cx6 *eeprom, bool enable) +{ + u16 command; + + /* start the command */ + eeprom_93cx6_startup(eeprom); + + /* create command to enable/disable */ + + command = enable ? PCI_EEPROM_EWEN_OPCODE : PCI_EEPROM_EWDS_OPCODE; + command <<= (eeprom->width - 2); + + eeprom_93cx6_write_bits(eeprom, command, + PCI_EEPROM_WIDTH_OPCODE + eeprom->width); + + eeprom_93cx6_cleanup(eeprom); +} +EXPORT_SYMBOL_GPL(eeprom_93cx6_wren); + +/** + * eeprom_93cx6_write - write data to the EEPROM + * @eeprom: Pointer to eeprom structure + * @addr: Address to write data to. + * @data: The data to write to address @addr. + * + * Write the @data to the specified @addr in the EEPROM and + * waiting for the device to finish writing. + * + * Note, since we do not expect large number of write operations + * we use msleep() to delay in between parts of the operation to + * avoid using excessive amounts of CPU time busy waiting. + */ +void eeprom_93cx6_write(struct eeprom_93cx6 *eeprom, u8 addr, u16 data) +{ + int timeout = 100; + u16 command; + + /* start the command */ + eeprom_93cx6_startup(eeprom); + + command = PCI_EEPROM_WRITE_OPCODE << eeprom->width; + command |= addr; + + /* send write command */ + eeprom_93cx6_write_bits(eeprom, command, + PCI_EEPROM_WIDTH_OPCODE + eeprom->width); + + /* send data */ + eeprom_93cx6_write_bits(eeprom, data, 16); + + /* get ready to check for busy */ + eeprom->drive_data = 0; + eeprom->reg_chip_select = 1; + eeprom->register_write(eeprom); + + /* wait at-least 250ns to get DO to be the busy signal */ + msleep(1); + + /* wait for DO to go high to signify finish */ + + while (true) { + eeprom->register_read(eeprom); + + if (eeprom->reg_data_out) + break; + + msleep(1); + + if (--timeout <= 0) { + printk(KERN_ERR "%s: timeout\n", __func__); + break; + } + } + + eeprom_93cx6_cleanup(eeprom); +} +EXPORT_SYMBOL_GPL(eeprom_93cx6_write); Index: b/include/linux/eeprom_93cx6.h =================================================================== --- a/include/linux/eeprom_93cx6.h 2009-10-06 15:51:18.000000000 +0100 +++ b/include/linux/eeprom_93cx6.h 2009-10-06 15:53:16.000000000 +0100 @@ -32,6 +32,7 @@ #define PCI_EEPROM_WIDTH_93C66 8 #define PCI_EEPROM_WIDTH_OPCODE 3 #define PCI_EEPROM_WRITE_OPCODE 0x05 +#define PCI_EEPROM_ERASE_OPCODE 0x07 #define PCI_EEPROM_READ_OPCODE 0x06 #define PCI_EEPROM_EWDS_OPCODE 0x10 #define PCI_EEPROM_EWEN_OPCODE 0x13 @@ -73,3 +74,9 @@ extern void eeprom_93cx6_read(struct eep const u8 word, u16 *data); extern void eeprom_93cx6_multiread(struct eeprom_93cx6 *eeprom, const u8 word, __le16 *data, const u16 words); + +extern void eeprom_93cx6_wren(struct eeprom_93cx6 *eeprom, bool enable); + +extern void eeprom_93cx6_write(struct eeprom_93cx6 *eeprom, + u8 addr, u16 data); + ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-12-07 12:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20091207121727.016092171@fluff.org.uk>
2009-12-07 12:17 ` [patch 1/9] eeprom_93cx6: Add data direction control Ben Dooks
2009-12-07 12:21 ` Jean Delvare
2009-12-07 12:24 ` Ben Dooks
2009-12-07 12:17 ` [patch 2/9] eeprom_93cx6: Add write support Ben Dooks
[not found] <20091207121501.819539008@fluff.org.uk>
2009-12-07 12:15 ` ben
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®