1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-09-16 05:48:58 +03:00

danube eeprom cleanup

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@9762 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
blogic 2007-12-15 00:04:32 +00:00
parent 268d096b51
commit 345bce368b

View File

@ -61,15 +61,6 @@
/* allow the user to set the major device number */ /* allow the user to set the major device number */
static int danube_eeprom_maj = 0; static int danube_eeprom_maj = 0;
static ssize_t danube_eeprom_fops_read (struct file *, char *, size_t, loff_t *);
static ssize_t danube_eeprom_fops_write (struct file *, const char *, size_t,
loff_t *);
static int danube_eeprom_ioctl (struct inode *, struct file *, unsigned int,
unsigned long);
static int danube_eeprom_open (struct inode *, struct file *);
static int danube_eeprom_close (struct inode *, struct file *);
//ifx_ssc.c
extern int ifx_ssc_init (void); extern int ifx_ssc_init (void);
extern int ifx_ssc_open (struct inode *inode, struct file *filp); extern int ifx_ssc_open (struct inode *inode, struct file *filp);
extern int ifx_ssc_close (struct inode *inode, struct file *filp); extern int ifx_ssc_close (struct inode *inode, struct file *filp);
@ -98,63 +89,30 @@ extern int ifx_ssc_rx (char *rx_buf, unsigned int rx_len);
#define EEPROM_SIZE 512 #define EEPROM_SIZE 512
static int static int
eeprom_rdsr (char *status) eeprom_rdsr (void)
{ {
int ret = 0; int ret = 0;
unsigned char cmd = EEPROM_RDSR; unsigned char cmd = EEPROM_RDSR;
unsigned long flag; unsigned long flag;
char status;
local_irq_save(flag); local_irq_save(flag);
if ((ret = ifx_ssc_cs_low (EEPROM_CS))) if ((ret = ifx_ssc_cs_low(EEPROM_CS)) == 0)
{ if ((ret = ifx_ssc_txrx(&cmd, 1, &status, 1)) >= 0)
local_irq_restore(flag); ret = status & 1;
goto out;
}
if ((ret = ifx_ssc_txrx (&cmd, 1, status, 1)) < 0)
{
ifx_ssc_cs_high(EEPROM_CS); ifx_ssc_cs_high(EEPROM_CS);
local_irq_restore(flag); local_irq_restore(flag);
goto out;
}
if ((ret = ifx_ssc_cs_high(EEPROM_CS)))
{
local_irq_restore(flag);
goto out;
}
local_irq_restore(flag);
out:
return ret; return ret;
} }
static inline int void
eeprom_wip_over (void) eeprom_wip_over (void)
{ {
int ret = 0; while (eeprom_rdsr())
unsigned char status; printk("waiting for eeprom\n");
while (1)
{
ret = eeprom_rdsr(&status);
printk("status %x \n", status);
if (ret)
{
printk("read back status fails %d\n", ret);
break;
}
if (((status) & 1) != 0)
printk("read back status not zero %x\n", status);
else
break;
}
return ret;
} }
static int static int
@ -165,29 +123,16 @@ eeprom_wren (void)
unsigned long flag; unsigned long flag;
local_irq_save(flag); local_irq_save(flag);
if ((ret = ifx_ssc_cs_low(EEPROM_CS))) if ((ret = ifx_ssc_cs_low(EEPROM_CS)) == 0)
{ if ((ret = ifx_ssc_tx(&cmd, 1)) >= 0)
local_irq_restore(flag); ret = 0;
goto out;
}
if ((ret = ifx_ssc_tx(&cmd, 1)) < 0)
{
ifx_ssc_cs_high(EEPROM_CS); ifx_ssc_cs_high(EEPROM_CS);
local_irq_restore(flag); local_irq_restore(flag);
goto out;
}
if ((ret = ifx_ssc_cs_high(EEPROM_CS))) if (!ret)
{
local_irq_restore(flag);
goto out;
}
local_irq_restore(flag);
eeprom_wip_over(); eeprom_wip_over();
out:
return ret; return ret;
} }