mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-19 21:58:04 +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 */
|
/* 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user