mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-23 23:42:43 +00:00
danube eeprom cleanup
SVN-Revision: 9762
This commit is contained in:
parent
880d600f71
commit
66fea87684
@ -61,15 +61,6 @@
|
||||
/* allow the user to set the major device number */
|
||||
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_open (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
|
||||
|
||||
static int
|
||||
eeprom_rdsr (char *status)
|
||||
eeprom_rdsr (void)
|
||||
{
|
||||
int ret = 0;
|
||||
unsigned char cmd = EEPROM_RDSR;
|
||||
unsigned long flag;
|
||||
char status;
|
||||
|
||||
local_irq_save(flag);
|
||||
|
||||
if ((ret = ifx_ssc_cs_low (EEPROM_CS)))
|
||||
{
|
||||
local_irq_restore(flag);
|
||||
goto out;
|
||||
}
|
||||
if ((ret = ifx_ssc_cs_low(EEPROM_CS)) == 0)
|
||||
if ((ret = ifx_ssc_txrx(&cmd, 1, &status, 1)) >= 0)
|
||||
ret = status & 1;
|
||||
|
||||
if ((ret = ifx_ssc_txrx (&cmd, 1, status, 1)) < 0)
|
||||
{
|
||||
ifx_ssc_cs_high(EEPROM_CS);
|
||||
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;
|
||||
}
|
||||
|
||||
static inline int
|
||||
void
|
||||
eeprom_wip_over (void)
|
||||
{
|
||||
int ret = 0;
|
||||
unsigned char status;
|
||||
|
||||
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;
|
||||
while (eeprom_rdsr())
|
||||
printk("waiting for eeprom\n");
|
||||
}
|
||||
|
||||
static int
|
||||
@ -165,29 +123,16 @@ eeprom_wren (void)
|
||||
unsigned long flag;
|
||||
|
||||
local_irq_save(flag);
|
||||
if ((ret = ifx_ssc_cs_low(EEPROM_CS)))
|
||||
{
|
||||
local_irq_restore(flag);
|
||||
goto out;
|
||||
}
|
||||
if ((ret = ifx_ssc_cs_low(EEPROM_CS)) == 0)
|
||||
if ((ret = ifx_ssc_tx(&cmd, 1)) >= 0)
|
||||
ret = 0;
|
||||
|
||||
if ((ret = ifx_ssc_tx(&cmd, 1)) < 0)
|
||||
{
|
||||
ifx_ssc_cs_high(EEPROM_CS);
|
||||
local_irq_restore(flag);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if ((ret = ifx_ssc_cs_high(EEPROM_CS)))
|
||||
{
|
||||
local_irq_restore(flag);
|
||||
goto out;
|
||||
}
|
||||
|
||||
local_irq_restore(flag);
|
||||
if (!ret)
|
||||
eeprom_wip_over();
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user