For SD card, use parameters generated by kernel config utility.

This commit is contained in:
Serge Vakulenko
2015-09-19 21:58:45 -07:00
parent 9c749994c1
commit 4ca4a58468
40 changed files with 42 additions and 286 deletions

View File

@@ -49,9 +49,6 @@ controller spi4 # SD card
device sd0 at spi4
pins RF3, RB13 # select pin, enable pin
options "SD0_MHZ=10" # speed 10 MHz
options "SD0_PORT=4" # at spi4 TODO: delete
options "SD0_CS_PORT=TRISF" # for chip select... TODO: delete
options "SD0_CS_PIN=3" # ...use pin RF3 TODO: delete
signal "SD0_ENA" pin RB13 # SD enable signal
# ADC driver

View File

@@ -14,9 +14,6 @@ PARAM += -DLED_KERNEL_PORT=TRISA -DLED_KERNEL_PIN=15
PARAM += -DNMOUNT=3
PARAM += -DPARTITION='sdramp0:sa@2048,fs@14000'
PARAM += -DKERNEL_EXECUTABLE_RAM
PARAM += -DSD0_CS_PIN=3
PARAM += -DSD0_CS_PORT=TRISF
PARAM += -DSD0_PORT=4
PARAM += -DSD0_MHZ=10
PARAM += -DCONS_MINOR=2
PARAM += -DCONS_MAJOR=UART_MAJOR

View File

@@ -44,6 +44,3 @@ controller spi2 # SD card
# SD card
device sd0 at spi2 pin RD1 # select pin
options "SD0_MHZ=16" # speed 16 MHz
options "SD0_PORT=2" # at spi2 TODO: delete
options "SD0_CS_PORT=TRISD" # for chip select... TODO: delete
options "SD0_CS_PIN=1" # ...use pin RD1 TODO: delete

View File

@@ -6,9 +6,6 @@ PARAM += -DSD_ENABLED
PARAM += -DLED_TTY_PORT=TRISD -DLED_TTY_PIN=12
PARAM += -DLED_DISK_PORT=TRISD -DLED_DISK_PIN=2
PARAM += -DLED_KERNEL_PORT=TRISD -DLED_KERNEL_PIN=3
PARAM += -DSD0_CS_PIN=1
PARAM += -DSD0_CS_PORT=TRISD
PARAM += -DSD0_PORT=2
PARAM += -DSD0_MHZ=16
PARAM += -DCONS_MINOR=0
PARAM += -DCONS_MAJOR=UART_MAJOR

View File

@@ -46,9 +46,6 @@ controller spi3 # SD card
# microSD card
device sd0 at spi3
pins RG12, RG13 # select pin, enable pin
options "SD0_PORT=3" # at spi3 TODO: delete
options "SD0_CS_PORT=TRISG" # for chip select... TODO: delete
options "SD0_CS_PIN=12" # ...use pin RG12 TODO: delete
signal "SD0_ENA" pin RG13 # SD card enable signal TODO: delete
# General purpose I/O ports

View File

@@ -46,9 +46,6 @@ controller spi3 # SD card
# microSD card
device sd0 at spi3
pins RG12, RG13 # select pin, enable pin
options "SD0_PORT=3" # at spi3 TODO: delete
options "SD0_CS_PORT=TRISG" # for chip select... TODO: delete
options "SD0_CS_PIN=12" # ...use pin RG12 TODO: delete
signal "SD0_ENA" pin RG13 # SD card enable signal TODO: delete
# General purpose I/O ports

View File

@@ -15,9 +15,6 @@ PARAM += -DPWM_ENABLED
PARAM += -DSD0_ENA_PORT=TRISG -DSD0_ENA_PIN=13
PARAM += -DLED_DISK_PORT=TRISC -DLED_DISK_PIN=1
PARAM += -DLED_KERNEL_PORT=TRISB -DLED_KERNEL_PIN=15
PARAM += -DSD0_CS_PIN=12
PARAM += -DSD0_CS_PORT=TRISG
PARAM += -DSD0_PORT=3
PARAM += -DUSB_NUM_STRING_DESCRIPTORS=3
PARAM += -DUSB_MAX_EP_NUMBER=3
PARAM += -DCONS_MAJOR=UARTUSB_MAJOR

View File

@@ -45,9 +45,6 @@ controller spi3 # SD card
# microSD card
device sd0 at spi3
pins RD5, RB13 # select pin, enable pin
options "SD0_PORT=3" # at spi3 TODO: delete
options "SD0_CS_PORT=TRISD" # for chip select... TODO: delete
options "SD0_CS_PIN=5" # ...use pin RD5 TODO: delete
signal "SD0_ENA" pin RB13 # SD card enable signal TODO: delete
# General purpose I/O ports

View File

@@ -45,9 +45,6 @@ controller spi3 # SD card
# microSD card
device sd0 at spi3
pins RD5, RB13 # select pin, enable pin
options "SD0_PORT=3" # at spi3 TODO: delete
options "SD0_CS_PORT=TRISD" # for chip select... TODO: delete
options "SD0_CS_PIN=5" # ...use pin RD5 TODO: delete
signal "SD0_ENA" pin RB13 # SD card enable signal TODO: delete
# General purpose I/O ports

View File

@@ -14,9 +14,6 @@ PARAM += -DPWM_ENABLED
PARAM += -DSD0_ENA_PORT=TRISB -DSD0_ENA_PIN=13
PARAM += -DLED_DISK_PORT=TRISB -DLED_DISK_PIN=12
PARAM += -DLED_KERNEL_PORT=TRISB -DLED_KERNEL_PIN=15
PARAM += -DSD0_CS_PIN=5
PARAM += -DSD0_CS_PORT=TRISD
PARAM += -DSD0_PORT=3
PARAM += -DUSB_NUM_STRING_DESCRIPTORS=3
PARAM += -DUSB_MAX_EP_NUMBER=3
PARAM += -DCONS_MAJOR=UARTUSB_MAJOR

View File

@@ -350,34 +350,32 @@ exception(frame)
break;
#ifdef UART1_ENABLED
case PIC32_VECT_U1: /* UART1 */
uartintr(makedev(UART_MAJOR,0));
uartintr(makedev(UART_MAJOR, 0));
break;
#endif
#ifdef UART2_ENABLED
case PIC32_VECT_U2: /* UART2 */
uartintr(makedev(UART_MAJOR,1));
uartintr(makedev(UART_MAJOR, 1));
break;
#endif
#ifdef UART3_ENABLED
case PIC32_VECT_U3: /* UART3 */
uartintr(makedev(UART_MAJOR,2));
uartintr(makedev(UART_MAJOR, 2));
break;
#endif
#ifdef UART4_ENABLED
case PIC32_VECT_U4: /* UART4 */
uartintr(makedev(UART_MAJOR,3));
uartintr(makedev(UART_MAJOR, 3));
break;
#endif
#ifdef UART5_ENABLED
case PIC32_VECT_U5: /* UART5 */
uartintr(makedev(UART_MAJOR,4));
uartintr(makedev(UART_MAJOR, 4));
break;
#endif
#ifdef UART6_ENABLED
case PIC32_VECT_U6: /* UART6 */
if (SD0_PORT != 2) {
uartintr(makedev(UART_MAJOR,5));
}
uartintr(makedev(UART_MAJOR, 5));
break;
#endif
#ifdef UARTUSB_ENABLED

View File

@@ -45,9 +45,6 @@ controller spi1 # SD card
# SD card
device sd0 at spi1 pin RB1 # select pin
options "SD0_MHZ=10" # speed 10 MHz
options "SD0_PORT=1" # at spi1 TODO: delete
options "SD0_CS_PORT=TRISB" # for chip select... TODO: delete
options "SD0_CS_PIN=1" # ...use pin RB1 TODO: delete
# General purpose I/O ports
# Flags define a mask of available pins

View File

@@ -16,9 +16,6 @@ PARAM += -DLED_SWAP_PORT=TRISA -DLED_SWAP_PIN=3
PARAM += -DLED_TTY_PORT=TRISA -DLED_TTY_PIN=2
PARAM += -DLED_KERNEL_PORT=TRISA -DLED_KERNEL_PIN=1
PARAM += -DLED_DISK_PORT=TRISA -DLED_DISK_PIN=0
PARAM += -DSD0_CS_PIN=1
PARAM += -DSD0_CS_PORT=TRISB
PARAM += -DSD0_PORT=1
PARAM += -DSD0_MHZ=10
PARAM += -DCONS_MINOR=1
PARAM += -DCONS_MAJOR=UART_MAJOR

View File

@@ -43,9 +43,6 @@ controller spi2 # SD card
# microSD card
device sd0 at spi2 pin RG9 # select pin
options "SD0_PORT=2" # sd0 at spi2 TODO: delete
options "SD0_CS_PORT=TRISG" # for chip select... TODO: delete
options "SD0_CS_PIN=9" # ...use pin RA9 TODO: delete
# General purpose I/O ports
# Flags define a mask of available pins

View File

@@ -48,9 +48,6 @@ controller spi2 # SD card
# microSD card
device sd0 at spi2 pin RG9 # select pin
options "SD0_PORT=2" # sd0 at spi2 TODO: delete
options "SD0_CS_PORT=TRISG" # for chip select... TODO: delete
options "SD0_CS_PIN=9" # ...use pin RA9 TODO: delete
options "SD0_MHZ=20" # increase data speed
# General purpose I/O ports

View File

@@ -13,9 +13,6 @@ PARAM += -DADC_ENABLED
PARAM += -DPWM_ENABLED
PARAM += -DGLCD_ENABLED
PARAM += -DLED_KERNEL_PORT=TRISE -DLED_KERNEL_PIN=5
PARAM += -DSD0_CS_PIN=9
PARAM += -DSD0_CS_PORT=TRISG
PARAM += -DSD0_PORT=2
PARAM += -DUSB_NUM_STRING_DESCRIPTORS=3
PARAM += -DUSB_MAX_EP_NUMBER=3
PARAM += -DCONS_MAJOR=UARTUSB_MAJOR

View File

@@ -93,17 +93,6 @@ const struct devspec gpiodevs[] = {
(a<<15 | b<<14 | c<<13 | d<<12 | e<<11 | f<<10 | g<<9 | h<<8 | \
i<<7 | j<<6 | k<<5 | l<<4 | m<<3 | n<<2 | o<<1 | p)
static const u_int gpio_pins_mx7 [NGPIO] =
{ /* Missing pins: */
MASK (1,1,0,0,0,1,1,0,1,1,1,1,1,1,1,1), /* A8, A11-A13 */
MASK (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),
MASK (1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,0), /* C0, C5-C11 */
MASK (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),
MASK (0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1), /* E10-E15 */
MASK (0,0,1,1,0,0,0,1,0,0,1,1,1,1,1,1), /* F6-F7, F9-F11, F14-F15 */
MASK (1,1,1,1,0,0,1,1,1,1,0,0,0,0,1,1), /* G2-G5, G10-G11 */
};
/*
* Mask of configured pins, default empty.
*/
@@ -116,104 +105,6 @@ u_int gpio_confmask [NGPIO];
#define PRINTDBG(...) /*empty*/
//#define PRINTDBG printf
/*
* If a port address matches a port number,
* clear a given bit in pin mask.
*/
static u_int
filter_out (mask, portnum, portaddr, pin)
register u_int mask;
u_int portnum;
volatile unsigned *portaddr;
{
register struct gpioreg *reg = portnum + (struct gpioreg*) &TRISA;
if ((unsigned) reg == (unsigned) portaddr)
mask &= ~(1 << pin);
return mask;
}
/*
* Some pins are not available in hardware or used by other drivers.
* Remove them from the mask.
*/
static u_int
gpio_filter (mask, portnum)
u_int mask;
u_int portnum;
{
mask &= gpio_pins_mx7 [portnum];
#ifdef LED_SWAP_PORT
mask = filter_out (mask, portnum, &LED_SWAP_PORT, LED_SWAP_PIN);
#endif
#ifdef LED_DISK_PORT
mask = filter_out (mask, portnum, &LED_DISK_PORT, LED_DISK_PIN);
#endif
#ifdef LED_KERNEL_PORT
mask = filter_out (mask, portnum, &LED_KERNEL_PORT, LED_KERNEL_PIN);
#endif
#ifdef LED_TTY_PORT
mask = filter_out (mask, portnum, &LED_TTY_PORT, LED_TTY_PIN);
#endif
#ifdef SD0_CS_PORT
mask = filter_out (mask, portnum, &SD0_CS_PORT, SD0_CS_PIN);
#endif
#ifdef SD1_CS_PORT
mask = filter_out (mask, portnum, &SD1_CS_PORT, SD1_CS_PIN);
#endif
#ifdef SD0_ENA_PORT
mask = filter_out (mask, portnum, &SD0_ENA_PORT, SD0_ENA_PIN);
#endif
#ifdef SD1_ENA_PORT
mask = filter_out (mask, portnum, &SD1_ENA_PORT, SD1_ENA_PIN);
#endif
#ifdef UART1_ENA_PORT
mask = filter_out (mask, portnum, &UART1_ENA_PORT, UART1_ENA_PIN);
#endif
#ifdef UART2_ENA_PORT
mask = filter_out (mask, portnum, &UART2_ENA_PORT, UART2_ENA_PIN);
#endif
#ifdef UART3_ENA_PORT
mask = filter_out (mask, portnum, &UART3_ENA_PORT, UART3_ENA_PIN);
#endif
#ifdef UART4_ENA_PORT
mask = filter_out (mask, portnum, &UART4_ENA_PORT, UART4_ENA_PIN);
#endif
#ifdef UART5_ENA_PORT
mask = filter_out (mask, portnum, &UART5_ENA_PORT, UART5_ENA_PIN);
#endif
#ifdef UART6_ENA_PORT
mask = filter_out (mask, portnum, &UART6_ENA_PORT, UART6_ENA_PIN);
#endif
#ifdef SW_DATA_PORT
mask = filter_out (mask, portnum, &SW_DATA_PORT, SW_DATA_PIN);
#endif
#ifdef SW_LDA_PORT
mask = filter_out (mask, portnum, &SW_LDA_PORT, SW_LDA_PIN);
#endif
#ifdef SW_RD_PORT
mask = filter_out (mask, portnum, &SW_RD_PORT, SW_RD_PIN);
#endif
#ifdef SW_WR_PORT
mask = filter_out (mask, portnum, &SW_WR_PORT, SW_WR_PIN);
#endif
#ifdef POWER_ENABLED
#ifdef POWER_SWITCH_PORT
mask = filter_out (mask, portnum, &POWER_SWITCH_PORT, POWER_SWITCH_PIN);
#endif
#ifdef POWER_LED_PORT
mask = filter_out (mask, portnum, &POWER_LED_PORT, POWER_LED_PIN);
#endif
#ifdef POWER_CONTROL_PORT
mask = filter_out (mask, portnum, &POWER_CONTROL_PORT, POWER_CONTROL_PIN);
#endif
#endif
return mask;
}
static void
gpio_print (dev, buf)
dev_t dev;
@@ -539,7 +430,7 @@ gpioioctl (dev, cmd, addr, flag)
reg = unit + (struct gpioreg*) &TRISA;
mask = (u_int) addr & 0xffff;
if (cmd & GPIO_COMMAND & (GPIO_CONFIN | GPIO_CONFOUT | GPIO_CONFOD))
mask = gpio_filter (mask, unit);
mask = mask;
else
mask &= gpio_confmask[unit];

View File

@@ -45,9 +45,6 @@ controller spi2 # SD card
# microSD card
device sd0 at spi2 pin RC14 # select pin
options "SD0_MHZ=10" # speed 10 MHz
options "SD0_PORT=2" # at spi2 TODO: delete
options "SD0_CS_PORT=TRISC" # for chip select... TODO: use flags
options "SD0_CS_PIN=14" # ...use pin RC14 TODO: use flags
# General purpose I/O ports
# Flags define a mask of available pins

View File

@@ -15,9 +15,6 @@ PARAM += -DGPIO6_ENABLED
PARAM += -DADC_ENABLED
PARAM += -DPWM_ENABLED
PARAM += -DLED_KERNEL_PORT=TRISA -DLED_KERNEL_PIN=3
PARAM += -DSD0_CS_PIN=14
PARAM += -DSD0_CS_PORT=TRISC
PARAM += -DSD0_PORT=2
PARAM += -DSD0_MHZ=10
PARAM += -DCONS_MINOR=0
PARAM += -DCONS_MAJOR=UART_MAJOR

View File

@@ -43,9 +43,6 @@ controller spi4 # SD card
# microSD card
device sd0 at spi4 pin RA1 # select pin
options "SD0_PORT=4" # at spi3 TODO: delete
options "SD0_CS_PORT=TRISA" # for chip select... TODO: delete
options "SD0_CS_PIN=1" # ...use pin RA1 TODO: delete
# General purpose I/O ports
# Flags define a mask of available pins

View File

@@ -14,9 +14,6 @@ PARAM += -DADC_ENABLED
PARAM += -DPWM_ENABLED
PARAM += -DLED_DISK_PORT=TRISE -DLED_DISK_PIN=1
PARAM += -DLED_KERNEL_PORT=TRISE -DLED_KERNEL_PIN=0 -DLED_KERNEL_INVERT
PARAM += -DSD0_CS_PIN=1
PARAM += -DSD0_CS_PORT=TRISA
PARAM += -DSD0_PORT=4
PARAM += -DUSB_NUM_STRING_DESCRIPTORS=3
PARAM += -DUSB_MAX_EP_NUMBER=3
PARAM += -DCONS_MAJOR=UARTUSB_MAJOR

View File

@@ -44,9 +44,6 @@ controller spi4 # SD card
# microSD card
device sd0 at spi4 pin RE0 # select pin
options "SD0_PORT=4" # at spi3 TODO: delete
options "SD0_CS_PORT=TRISE" # for chip select... TODO: delete
options "SD0_CS_PIN=0" # ...use pin RE0 TODO: delete
# General purpose I/O ports
# Flags define a mask of available pins

View File

@@ -14,9 +14,6 @@ PARAM += -DADC_ENABLED
PARAM += -DPWM_ENABLED
PARAM += -DLED_DISK_PORT=TRISE -DLED_DISK_PIN=1
PARAM += -DLED_KERNEL_PORT=TRISF -DLED_KERNEL_PIN=0 -DLED_KERNEL_INVERT
PARAM += -DSD0_CS_PIN=0
PARAM += -DSD0_CS_PORT=TRISE
PARAM += -DSD0_PORT=4
PARAM += -DUSB_NUM_STRING_DESCRIPTORS=3
PARAM += -DUSB_MAX_EP_NUMBER=3
PARAM += -DCONS_MAJOR=UARTUSB_MAJOR

View File

@@ -47,9 +47,6 @@ controller spi1 # SD card
# microSD card
device sd0 at spi1 pin RA9 # select pin
options "SD0_PORT=1" # sd0 at spi1 TODO: delete
options "SD0_CS_PORT=TRISA" # for sd0 chip select...TODO: delete
options "SD0_CS_PIN=9" # ...use pin RA9 TODO: delete
options "SD0_MHZ=8" # speed 8 MHz
# General purpose I/O ports

View File

@@ -18,9 +18,6 @@ PARAM += -DLED_TTY_PORT=TRISA -DLED_TTY_PIN=1 -DLED_TTY_INVERT
PARAM += -DLED_SWAP_PORT=TRISD -DLED_SWAP_PIN=9 -DLED_SWAP_INVERT
PARAM += -DLED_KERNEL_PORT=TRISA -DLED_KERNEL_PIN=0 -DLED_KERNEL_INVERT
PARAM += -DSD0_MHZ=8
PARAM += -DSD0_CS_PIN=9
PARAM += -DSD0_CS_PORT=TRISA
PARAM += -DSD0_PORT=1
PARAM += -DUSB_NUM_STRING_DESCRIPTORS=3
PARAM += -DUSB_MAX_EP_NUMBER=3
PARAM += -DCONS_MAJOR=UARTUSB_MAJOR

View File

@@ -40,9 +40,6 @@ controller spi2 # SD card
# microSD card
device sd0 at spi2 pin RG9 # select pin
options "SD0_MHZ=10" # speed 10 MHz
options "SD0_PORT=2" # at spi2 TODO: delete
options "SD0_CS_PORT=TRISG" # for chip select... TODO: delete
options "SD0_CS_PIN=9" # ...use pin RG9 TODO: delete
# ADC driver
device adc

View File

@@ -40,9 +40,6 @@ controller spi4 # RAM disk: spirams
# microSD card
device sd0 at spi2 pin RG9 # select pin
options "SD0_MHZ=10" # speed 10 MHz
options "SD0_PORT=2" # at spi2 TODO: delete
options "SD0_CS_PORT=TRISG" # for chip select... TODO: delete
options "SD0_CS_PIN=9" # ...use pin RG9 TODO: delete
# ADC driver
device adc

View File

@@ -6,9 +6,6 @@ PARAM += -DSD_ENABLED
PARAM += -DADC_ENABLED
PARAM += -DPWM_ENABLED
PARAM += -DHXTFT_ENABLED
PARAM += -DSD0_CS_PIN=9
PARAM += -DSD0_CS_PORT=TRISG
PARAM += -DSD0_PORT=2
PARAM += -DSD0_MHZ=10
PARAM += -DCONS_MINOR=0
PARAM += -DCONS_MAJOR=UART_MAJOR

View File

@@ -42,9 +42,6 @@ controller spi2 # SD card
# microSD card
device sd0 at spi2 pin RB13 # select pin
options "SD0_PORT=2" # at spi2 TODO: delete
options "SD0_CS_PORT=TRISB" # for chip select... TODO: delete
options "SD0_CS_PIN=13" # ...use pin RB13 TODO: delete
# General purpose I/O ports
# Flags define a mask of available pins

View File

@@ -12,9 +12,6 @@ PARAM += -DGPIO6_ENABLED
PARAM += -DADC_ENABLED
PARAM += -DPWM_ENABLED
PARAM += -DLED_KERNEL_PORT=TRISD -DLED_KERNEL_PIN=1 -DLED_KERNEL_INVERT
PARAM += -DSD0_CS_PIN=13
PARAM += -DSD0_CS_PORT=TRISB
PARAM += -DSD0_PORT=2
PARAM += -DUSB_NUM_STRING_DESCRIPTORS=3
PARAM += -DUSB_MAX_EP_NUMBER=3
PARAM += -DCONS_MAJOR=UARTUSB_MAJOR

View File

@@ -254,7 +254,6 @@ int card_init(int unit)
sd_type[unit] = 2;
}
/* Send repeatedly SEND_OP until Idle terminates. */
for (i=0; ; i++)
{
@@ -296,13 +295,9 @@ int card_init(int unit)
sd_type[unit] = 3;
}
}
/* Fast speed. */
if(unit == 0)
spi_brg(sd_fd[unit],SD0_MHZ * 1000);
#ifdef SD1_PORT
if(unit == 1)
spi_brg(sd_fd[unit],SD1_MHZ * 1000);
#endif
return 1;
}
@@ -532,45 +527,6 @@ again:
void sd_preinit (int unit)
{
if (unit >= NSD)
return;
int fd = -1;
if(unit==0)
fd = spi_open(SD0_PORT,(unsigned int *)&SD0_CS_PORT,SD0_CS_PIN);
#ifdef SD1_PORT
if(unit==1)
fd = spi_open(SD1_PORT,(unsigned int *)&SD1_CS_PORT,SD1_CS_PIN);
#endif
if(fd==-1)
{
printf("sd%d: Cannot open port\n",unit);
return;
}
sd_fd[unit] = fd;
#ifdef SD0_ENA_PORT
/* Enable SD0 phy - pin is assumed to be active low */
TRIS_CLR(SD0_ENA_PORT) = 1 << SD0_ENA_PIN;
LAT_CLR(SD0_ENA_PORT) = 1 << SD0_ENA_PIN;
udelay (1000);
#endif
#ifdef SD1_ENA_PORT
/* Enable SD1 phy - pin is assumed to be active low */
TRIS_CLR(SD1_ENA_PORT) = 1 << SD1_ENA_PIN;
LAT_CLR(SD1_ENA_PORT) = 1 << SD1_ENA_PIN;
udelay (1000);
#endif
spi_brg(fd, SD0_MHZ * 1000);
spi_set(fd, PIC32_SPICON_CKE);
//printf ("sd%d: port %s, select pin R%c%d\n", unit,
// spi_name(fd), spi_csname(fd), spi_cspin(fd));
}
int sdinit (int unit, int flag)
@@ -655,13 +611,44 @@ sdprobe(config)
struct conf_device *config;
{
int unit = config->dev_unit;
int cs;
int cs = config->dev_pins[0];
if (unit < 0 || unit >= NSD)
return 0;
cs = config->dev_pins[0];
printf("sd%u: port SPI%d, pin cs=R%c%d\n", unit,
config->dev_ctlr, gpio_portname(cs), gpio_pinno(cs));
int port = (cs >> 4) - 1;
int pin = cs & 15;
struct gpioreg *base = port + (struct gpioreg*) &TRISA;
int fd = spi_open(config->dev_ctlr, (unsigned int*) base, pin);
if (fd < 0) {
printf("sd%d: Cannot open SPI port\n", unit);
return 0;
}
sd_fd[unit] = fd;
#ifdef SD0_ENA_PORT
if (unit == 0) {
/* Enable SD0 phy - pin is assumed to be active low */
TRIS_CLR(SD0_ENA_PORT) = 1 << SD0_ENA_PIN;
LAT_CLR(SD0_ENA_PORT) = 1 << SD0_ENA_PIN;
udelay (1000);
}
#endif
#ifdef SD1_ENA_PORT
if (unit == 1) {
/* Enable SD1 phy - pin is assumed to be active low */
TRIS_CLR(SD1_ENA_PORT) = 1 << SD1_ENA_PIN;
LAT_CLR(SD1_ENA_PORT) = 1 << SD1_ENA_PIN;
udelay (1000);
}
#endif
spi_brg(fd, SD0_MHZ * 1000);
spi_set(fd, PIC32_SPICON_CKE);
return 1;
}

View File

@@ -44,9 +44,6 @@ controller spi2 # SD card
# microSD card
device sd0 at spi2 pin RG9 # select pin
options "SD0_PORT=2" # sd0 at spi2 TODO: delete
options "SD0_CS_PORT=TRISG" # for chip select... TODO: delete
options "SD0_CS_PIN=9" # ...use pin RA9 TODO: delete
# General purpose I/O ports
# Flags define a mask of available pins

View File

@@ -13,9 +13,6 @@ PARAM += -DADC_ENABLED
PARAM += -DPWM_ENABLED
PARAM += -DGLCD_ENABLED
PARAM += -DLED_KERNEL_PORT=TRISE -DLED_KERNEL_PIN=7
PARAM += -DSD0_CS_PIN=9
PARAM += -DSD0_CS_PORT=TRISG
PARAM += -DSD0_PORT=2
PARAM += -DUSB_NUM_STRING_DESCRIPTORS=3
PARAM += -DUSB_MAX_EP_NUMBER=3
PARAM += -DCONS_MAJOR=UARTUSB_MAJOR

View File

@@ -44,9 +44,6 @@ controller spi1 # SD card
# SD card
device sd0 at spi1 pin RB1 # select pin RB1
options "SD0_PORT=1" # at spi1 TODO: delete
options "SD0_CS_PORT=TRISB" # for chip select... TODO: delete
options "SD0_CS_PIN=1" # ...use pin RB1 TODO: delete
# General purpose I/O ports
# Flags define a mask of available pins

View File

@@ -14,9 +14,6 @@ PARAM += -DADC_ENABLED
PARAM += -DPWM_ENABLED
PARAM += -DLED_KERNEL_PORT=TRISD -DLED_KERNEL_PIN=2
PARAM += -DLED_DISK_PORT=TRISD -DLED_DISK_PIN=1
PARAM += -DSD0_CS_PIN=1
PARAM += -DSD0_CS_PORT=TRISB
PARAM += -DSD0_PORT=1
PARAM += -DUSB_NUM_STRING_DESCRIPTORS=3
PARAM += -DUSB_MAX_EP_NUMBER=3
PARAM += -DCONS_MAJOR=UARTUSB_MAJOR

View File

@@ -48,12 +48,6 @@ controller spi1 # SD card
# microSD card
device sd0 at spi1 pin RA9 # select pin
device sd1 at spi1 pin RA10 # select pin
options "SD0_PORT=1" # sd0 at spi1 TODO: delete
options "SD0_CS_PORT=TRISA" # for sd0 chip select...TODO: delete
options "SD0_CS_PIN=9" # ...use pin RA9 TODO: delete
options "SD1_PORT=1" # sd1 at spi1 TODO: delete
options "SD1_CS_PORT=TRISA" # for sd1 chip select...TODO: delete
options "SD1_CS_PIN=10" # ...use pin RA9 TODO: delete
# General purpose I/O ports
# Flags define a mask of available pins

View File

@@ -46,12 +46,6 @@ controller spi1 # SD card
# microSD card
device sd0 at spi1 pin RA9 # select pin
device sd1 at spi1 pin RA10 # select pin
options "SD0_PORT=1" # sd0 at spi1 TODO: delete
options "SD0_CS_PORT=TRISA" # for sd0 chip select...TODO: delete
options "SD0_CS_PIN=9" # ...use pin RA9 TODO: delete
options "SD1_PORT=1" # sd1 at spi1 TODO: delete
options "SD1_CS_PORT=TRISA" # for sd1 chip select...TODO: delete
options "SD1_CS_PIN=10" # ...use pin RA9 TODO: delete
# General purpose I/O ports
# Flags define a mask of available pins

View File

@@ -17,12 +17,6 @@ PARAM += -DLED_TTY_PORT=TRISE -DLED_TTY_PIN=3 -DLED_TTY_INVERT
PARAM += -DLED_SWAP_PORT=TRISE -DLED_SWAP_PIN=0 -DLED_SWAP_INVERT
PARAM += -DLED_DISK_PORT=TRISE -DLED_DISK_PIN=1 -DLED_DISK_INVERT
PARAM += -DLED_KERNEL_PORT=TRISE -DLED_KERNEL_PIN=2 -DLED_KERNEL_INVERT
PARAM += -DSD1_CS_PIN=10
PARAM += -DSD1_CS_PORT=TRISA
PARAM += -DSD1_PORT=1
PARAM += -DSD0_CS_PIN=9
PARAM += -DSD0_CS_PORT=TRISA
PARAM += -DSD0_PORT=1
PARAM += -DUSB_NUM_STRING_DESCRIPTORS=3
PARAM += -DUSB_MAX_EP_NUMBER=3
PARAM += -DCONS_MAJOR=UARTUSB_MAJOR

View File

@@ -42,9 +42,6 @@ controller spi2 # SD card
# microSD card
device sd0 at spi2 pin RD4 # select pin RD4
options "SD0_MHZ=10" # speed 10 MHz
options "SD0_PORT=2" # at spi2 TODO: delete
options "SD0_CS_PORT=TRISD" # for chip select... TODO: delete
options "SD0_CS_PIN=4" # ...use pin RD4 TODO: delete
# General purpose I/O ports
# Flags define a mask of available pins

View File

@@ -15,9 +15,6 @@ PARAM += -DPWM_ENABLED
PARAM += -DLED_TTY_PORT=TRISA -DLED_TTY_PIN=1
PARAM += -DLED_DISK_PORT=TRISF -DLED_DISK_PIN=0
PARAM += -DLED_KERNEL_PORT=TRISA -DLED_KERNEL_PIN=0
PARAM += -DSD0_CS_PIN=4
PARAM += -DSD0_CS_PORT=TRISD
PARAM += -DSD0_PORT=2
PARAM += -DSD0_MHZ=10
PARAM += -DCONS_MINOR=0
PARAM += -DCONS_MAJOR=UART_MAJOR