Subject: Re: test ahc patches, please? (patches attached)
To: None <current-users@netbsd.org>
From: David Young <dyoung@pobox.com>
List: current-users
Date: 04/25/2003 01:53:06
--7ZAtKRhVyVSsbBD2
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Fri, Apr 25, 2003 at 01:43:49AM -0500, David Young wrote:
> I need to read an SMC93cx6 EEPROM in a new wireless driver. With
> some small changes, I was able to re-use the code which ahc uses.
> Will somebody with an ahc review/test these patches before I commit them?
This time with the patches.
Dave
--
David Young OJC Technologies
dyoung@ojctech.com Urbana, IL * (217) 278-3933
--7ZAtKRhVyVSsbBD2
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=ahc-diffs
Index: sys/dev/ic/aic7xxx_seeprom.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/aic7xxx_seeprom.c,v
retrieving revision 1.7
diff -c -r1.7 aic7xxx_seeprom.c
*** sys/dev/ic/aic7xxx_seeprom.c 2003/04/19 19:33:30 1.7
--- sys/dev/ic/aic7xxx_seeprom.c 2003/04/25 06:33:54
***************
*** 104,109 ****
--- 104,110 ----
sd.sd_tag = ahc->tag;
sd.sd_bsh = ahc->bsh;
+ sd.sd_regsize = 1;
sd.sd_control_offset = SEECTL;
sd.sd_status_offset = SEECTL;
sd.sd_dataout_offset = SEECTL;
Index: sys/dev/ic/smc93cx6.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/smc93cx6.c,v
retrieving revision 1.9
diff -c -r1.9 smc93cx6.c
*** sys/dev/ic/smc93cx6.c 2001/11/13 13:14:45 1.9
--- sys/dev/ic/smc93cx6.c 2003/04/25 06:33:55
***************
*** 85,100 ****
unsigned char bits[3];
} seeprom_read = {3, {1, 1, 0}};
! /*
! * Wait for the SEERDY to go high; about 800 ns.
! */
! #define CLOCK_PULSE(sd, rdy) { \
int cpi = 1000; \
while ((SEEPROM_STATUS_INB(sd) & rdy) == 0 && cpi-- > 0) { \
; /* Do nothing */ \
} \
(void)SEEPROM_INB(sd); /* Clear clock */ \
! }
/*
* Read the serial EEPROM and returns 1 if successful and 0 if
--- 85,104 ----
unsigned char bits[3];
} seeprom_read = {3, {1, 1, 0}};
! #define CLOCK_PULSE(sd, rdy) do { \
! /* \
! * Wait for the SEERDY to go high; about 800 ns. \
! */ \
int cpi = 1000; \
+ if (rdy == 0) { \
+ DELAY(4); /* more than long enough */ \
+ break; \
+ } \
while ((SEEPROM_STATUS_INB(sd) & rdy) == 0 && cpi-- > 0) { \
; /* Do nothing */ \
} \
(void)SEEPROM_INB(sd); /* Clear clock */ \
! } while (0)
/*
* Read the serial EEPROM and returns 1 if successful and 0 if
***************
*** 110,116 ****
int i = 0;
u_int k = 0;
u_int16_t v;
! u_int8_t temp;
/*
* Read the requested registers of the seeprom. The loop
--- 114,120 ----
int i = 0;
u_int k = 0;
u_int16_t v;
! u_int32_t temp;
/*
* Read the requested registers of the seeprom. The loop
Index: sys/dev/ic/smc93cx6var.h
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/smc93cx6var.h,v
retrieving revision 1.5
diff -c -r1.5 smc93cx6var.h
*** sys/dev/ic/smc93cx6var.h 2000/03/15 02:08:31 1.5
--- sys/dev/ic/smc93cx6var.h 2003/04/25 06:33:58
***************
*** 48,63 ****
struct seeprom_descriptor {
bus_space_tag_t sd_tag;
bus_space_handle_t sd_bsh;
bus_size_t sd_control_offset;
bus_size_t sd_status_offset;
bus_size_t sd_dataout_offset;
seeprom_chip_t sd_chip;
! u_int16_t sd_MS;
! u_int16_t sd_RDY;
! u_int16_t sd_CS;
! u_int16_t sd_CK;
! u_int16_t sd_DO;
! u_int16_t sd_DI;
};
/*
--- 48,64 ----
struct seeprom_descriptor {
bus_space_tag_t sd_tag;
bus_space_handle_t sd_bsh;
+ bus_size_t sd_regsize;
bus_size_t sd_control_offset;
bus_size_t sd_status_offset;
bus_size_t sd_dataout_offset;
seeprom_chip_t sd_chip;
! u_int32_t sd_MS;
! u_int32_t sd_RDY;
! u_int32_t sd_CS;
! u_int32_t sd_CK;
! u_int32_t sd_DO;
! u_int32_t sd_DI;
};
/*
***************
*** 77,89 ****
*/
#define SEEPROM_INB(sd) \
! bus_space_read_1(sd->sd_tag, sd->sd_bsh, sd->sd_control_offset)
! #define SEEPROM_OUTB(sd, value) \
! bus_space_write_1(sd->sd_tag, sd->sd_bsh, sd->sd_control_offset, value)
#define SEEPROM_STATUS_INB(sd) \
! bus_space_read_1(sd->sd_tag, sd->sd_bsh, sd->sd_status_offset)
#define SEEPROM_DATA_INB(sd) \
! bus_space_read_1(sd->sd_tag, sd->sd_bsh, sd->sd_dataout_offset)
int read_seeprom(struct seeprom_descriptor *sd, u_int16_t *buf,
bus_size_t start_addr, bus_size_t count);
--- 78,111 ----
*/
#define SEEPROM_INB(sd) \
! (((sd)->sd_regsize == 4) \
! ? bus_space_read_4((sd)->sd_tag, (sd)->sd_bsh, \
! (sd)->sd_control_offset) \
! : bus_space_read_1((sd)->sd_tag, (sd)->sd_bsh, \
! (sd)->sd_control_offset))
!
! #define SEEPROM_OUTB(sd, value) do { \
! if ((sd)->sd_regsize == 4) \
! bus_space_write_4((sd)->sd_tag, (sd)->sd_bsh, \
! (sd)->sd_control_offset, (value)); \
! else \
! bus_space_write_1((sd)->sd_tag, (sd)->sd_bsh, \
! (sd)->sd_control_offset, (u_int8_t) (value)); \
! } while (0)
!
#define SEEPROM_STATUS_INB(sd) \
! (((sd)->sd_regsize == 4) \
! ? bus_space_read_4((sd)->sd_tag, (sd)->sd_bsh, \
! (sd)->sd_status_offset) \
! : bus_space_read_1((sd)->sd_tag, (sd)->sd_bsh, \
! (sd)->sd_status_offset))
!
#define SEEPROM_DATA_INB(sd) \
! (((sd)->sd_regsize == 4) \
! ? bus_space_read_4((sd)->sd_tag, (sd)->sd_bsh, \
! (sd)->sd_dataout_offset) \
! : bus_space_read_1((sd)->sd_tag, (sd)->sd_bsh, \
! (sd)->sd_dataout_offset))
int read_seeprom(struct seeprom_descriptor *sd, u_int16_t *buf,
bus_size_t start_addr, bus_size_t count);
--7ZAtKRhVyVSsbBD2--