mirror of
https://github.com/fail0verflow/mini.git
synced 2024-11-28 06:04:19 +01:00
Use symbolic names for SEEPROM pins
This commit is contained in:
parent
683ea6d8eb
commit
4d1a048d42
23
seeprom.c
23
seeprom.c
@ -2,6 +2,7 @@
|
||||
#include "utils.h"
|
||||
#include "hollywood.h"
|
||||
#include "start.h"
|
||||
#include "gpio.h"
|
||||
|
||||
#define gpio_delay() udelay(100)
|
||||
|
||||
@ -11,13 +12,13 @@ void send_bits(int b, int bits)
|
||||
while(bits--)
|
||||
{
|
||||
if(b & (1 << bits))
|
||||
set32(HW_GPIO1OUT, 0x1000);
|
||||
set32(HW_GPIO1OUT, GP_EEP_MOSI);
|
||||
else
|
||||
clear32(HW_GPIO1OUT, 0x1000);
|
||||
clear32(HW_GPIO1OUT, GP_EEP_MOSI);
|
||||
gpio_delay();
|
||||
set32(HW_GPIO1OUT, 0x800);
|
||||
set32(HW_GPIO1OUT, GP_EEP_CLK);
|
||||
gpio_delay();
|
||||
clear32(HW_GPIO1OUT, 0x800);
|
||||
clear32(HW_GPIO1OUT, GP_EEP_CLK);
|
||||
gpio_delay();
|
||||
}
|
||||
}
|
||||
@ -28,11 +29,11 @@ int recv_bits(int bits)
|
||||
while(bits--)
|
||||
{
|
||||
res <<= 1;
|
||||
set32(HW_GPIO1OUT, 0x800);
|
||||
set32(HW_GPIO1OUT, GP_EEP_CLK);
|
||||
gpio_delay();
|
||||
clear32(HW_GPIO1OUT, 0x800);
|
||||
clear32(HW_GPIO1OUT, GP_EEP_CLK);
|
||||
gpio_delay();
|
||||
res |= !!(read32(HW_GPIO1IN) & 0x2000);
|
||||
res |= !!(read32(HW_GPIO1IN) & GP_EEP_MISO);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@ -46,17 +47,17 @@ int seeprom_read(void *dst, int offset, int size)
|
||||
if(size & 1)
|
||||
return -1;
|
||||
|
||||
clear32(HW_GPIO1OUT, 0x800);
|
||||
clear32(HW_GPIO1OUT, 0x400);
|
||||
clear32(HW_GPIO1OUT, GP_EEP_CLK);
|
||||
clear32(HW_GPIO1OUT, GP_EEP_CS);
|
||||
gpio_delay();
|
||||
|
||||
for(i = 0; i < size; ++i)
|
||||
{
|
||||
set32(HW_GPIO1OUT, 0x400);
|
||||
set32(HW_GPIO1OUT, GP_EEP_CS);
|
||||
send_bits((0x600 | (offset + i)), 11);
|
||||
recv = recv_bits(16);
|
||||
*ptr++ = recv;
|
||||
clear32(HW_GPIO1OUT, 0x400);
|
||||
clear32(HW_GPIO1OUT, GP_EEP_CS);
|
||||
gpio_delay();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user