From 4ca4a58468868840040361ce60942a0ecac66afd Mon Sep 17 00:00:00 2001 From: Serge Vakulenko Date: Sat, 19 Sep 2015 21:58:45 -0700 Subject: [PATCH] For SD card, use parameters generated by kernel config utility. --- sys/pic32/32mxsdram/Config | 3 - sys/pic32/32mxsdram/Makefile | 3 - sys/pic32/baremetal/Config | 3 - sys/pic32/baremetal/Makefile | 3 - sys/pic32/duinomite-emega/Config | 3 - sys/pic32/duinomite-emega/Config-uart | 3 - sys/pic32/duinomite-emega/Makefile | 3 - sys/pic32/duinomite/Config | 3 - sys/pic32/duinomite/Config-uart | 3 - sys/pic32/duinomite/Makefile | 3 - sys/pic32/exception.c | 14 ++-- sys/pic32/explorer16/Config | 3 - sys/pic32/explorer16/Makefile | 3 - sys/pic32/fubarino/Config | 3 - sys/pic32/fubarino/Config-uart-sramc | 3 - sys/pic32/fubarino/Makefile | 3 - sys/pic32/gpio.c | 111 +------------------------- sys/pic32/max32/Config | 3 - sys/pic32/max32/Makefile | 3 - sys/pic32/maximite-color/Config | 3 - sys/pic32/maximite-color/Makefile | 3 - sys/pic32/maximite/Config | 3 - sys/pic32/maximite/Makefile | 3 - sys/pic32/mmb-mx7/Config | 3 - sys/pic32/mmb-mx7/Makefile | 3 - sys/pic32/picadillo/Config | 3 - sys/pic32/picadillo/Config-rambo | 3 - sys/pic32/picadillo/Makefile | 3 - sys/pic32/pinguino-micro/Config | 3 - sys/pic32/pinguino-micro/Makefile | 3 - sys/pic32/rd_sd.c | 83 ++++++++----------- sys/pic32/sdxl/Config | 3 - sys/pic32/sdxl/Makefile | 3 - sys/pic32/starter-kit/Config | 3 - sys/pic32/starter-kit/Makefile | 3 - sys/pic32/ubw32/Config | 6 -- sys/pic32/ubw32/Config-uart | 6 -- sys/pic32/ubw32/Makefile | 6 -- sys/pic32/wf32/Config | 3 - sys/pic32/wf32/Makefile | 3 - 40 files changed, 42 insertions(+), 286 deletions(-) diff --git a/sys/pic32/32mxsdram/Config b/sys/pic32/32mxsdram/Config index 52cacbe..9935104 100644 --- a/sys/pic32/32mxsdram/Config +++ b/sys/pic32/32mxsdram/Config @@ -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 diff --git a/sys/pic32/32mxsdram/Makefile b/sys/pic32/32mxsdram/Makefile index 769d1fb..636a5c1 100644 --- a/sys/pic32/32mxsdram/Makefile +++ b/sys/pic32/32mxsdram/Makefile @@ -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 diff --git a/sys/pic32/baremetal/Config b/sys/pic32/baremetal/Config index 5d0a777..815e4c3 100644 --- a/sys/pic32/baremetal/Config +++ b/sys/pic32/baremetal/Config @@ -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 diff --git a/sys/pic32/baremetal/Makefile b/sys/pic32/baremetal/Makefile index ba2182c..0fbf6ee 100644 --- a/sys/pic32/baremetal/Makefile +++ b/sys/pic32/baremetal/Makefile @@ -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 diff --git a/sys/pic32/duinomite-emega/Config b/sys/pic32/duinomite-emega/Config index 15c6dee..16abc36 100644 --- a/sys/pic32/duinomite-emega/Config +++ b/sys/pic32/duinomite-emega/Config @@ -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 diff --git a/sys/pic32/duinomite-emega/Config-uart b/sys/pic32/duinomite-emega/Config-uart index 74ded72..ed78203 100644 --- a/sys/pic32/duinomite-emega/Config-uart +++ b/sys/pic32/duinomite-emega/Config-uart @@ -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 diff --git a/sys/pic32/duinomite-emega/Makefile b/sys/pic32/duinomite-emega/Makefile index c975f04..3f71959 100644 --- a/sys/pic32/duinomite-emega/Makefile +++ b/sys/pic32/duinomite-emega/Makefile @@ -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 diff --git a/sys/pic32/duinomite/Config b/sys/pic32/duinomite/Config index c665852..45c0ecc 100644 --- a/sys/pic32/duinomite/Config +++ b/sys/pic32/duinomite/Config @@ -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 diff --git a/sys/pic32/duinomite/Config-uart b/sys/pic32/duinomite/Config-uart index 13934d3..53a62bc 100644 --- a/sys/pic32/duinomite/Config-uart +++ b/sys/pic32/duinomite/Config-uart @@ -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 diff --git a/sys/pic32/duinomite/Makefile b/sys/pic32/duinomite/Makefile index 50c4a9f..6543a46 100644 --- a/sys/pic32/duinomite/Makefile +++ b/sys/pic32/duinomite/Makefile @@ -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 diff --git a/sys/pic32/exception.c b/sys/pic32/exception.c index 4f2c3d3..7b9e90c 100644 --- a/sys/pic32/exception.c +++ b/sys/pic32/exception.c @@ -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 diff --git a/sys/pic32/explorer16/Config b/sys/pic32/explorer16/Config index 565f8c3..7b4d722 100644 --- a/sys/pic32/explorer16/Config +++ b/sys/pic32/explorer16/Config @@ -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 diff --git a/sys/pic32/explorer16/Makefile b/sys/pic32/explorer16/Makefile index 6dda8dd..617a886 100644 --- a/sys/pic32/explorer16/Makefile +++ b/sys/pic32/explorer16/Makefile @@ -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 diff --git a/sys/pic32/fubarino/Config b/sys/pic32/fubarino/Config index be188ee..6c2bc26 100644 --- a/sys/pic32/fubarino/Config +++ b/sys/pic32/fubarino/Config @@ -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 diff --git a/sys/pic32/fubarino/Config-uart-sramc b/sys/pic32/fubarino/Config-uart-sramc index 3fa98f8..27c6a22 100644 --- a/sys/pic32/fubarino/Config-uart-sramc +++ b/sys/pic32/fubarino/Config-uart-sramc @@ -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 diff --git a/sys/pic32/fubarino/Makefile b/sys/pic32/fubarino/Makefile index b03f2ae..e9ff7be 100644 --- a/sys/pic32/fubarino/Makefile +++ b/sys/pic32/fubarino/Makefile @@ -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 diff --git a/sys/pic32/gpio.c b/sys/pic32/gpio.c index 8d30cd9..bb32515 100644 --- a/sys/pic32/gpio.c +++ b/sys/pic32/gpio.c @@ -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]; diff --git a/sys/pic32/max32/Config b/sys/pic32/max32/Config index ce3eba3..ed07ed5 100644 --- a/sys/pic32/max32/Config +++ b/sys/pic32/max32/Config @@ -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 diff --git a/sys/pic32/max32/Makefile b/sys/pic32/max32/Makefile index 8396857..20eaf21 100644 --- a/sys/pic32/max32/Makefile +++ b/sys/pic32/max32/Makefile @@ -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 diff --git a/sys/pic32/maximite-color/Config b/sys/pic32/maximite-color/Config index 8015b95..eb114b7 100644 --- a/sys/pic32/maximite-color/Config +++ b/sys/pic32/maximite-color/Config @@ -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 diff --git a/sys/pic32/maximite-color/Makefile b/sys/pic32/maximite-color/Makefile index 070889e..f179b7f 100644 --- a/sys/pic32/maximite-color/Makefile +++ b/sys/pic32/maximite-color/Makefile @@ -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 diff --git a/sys/pic32/maximite/Config b/sys/pic32/maximite/Config index 4aeb82d..787ef4f 100644 --- a/sys/pic32/maximite/Config +++ b/sys/pic32/maximite/Config @@ -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 diff --git a/sys/pic32/maximite/Makefile b/sys/pic32/maximite/Makefile index 7596379..d550550 100644 --- a/sys/pic32/maximite/Makefile +++ b/sys/pic32/maximite/Makefile @@ -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 diff --git a/sys/pic32/mmb-mx7/Config b/sys/pic32/mmb-mx7/Config index c031dc0..2f187f1 100644 --- a/sys/pic32/mmb-mx7/Config +++ b/sys/pic32/mmb-mx7/Config @@ -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 diff --git a/sys/pic32/mmb-mx7/Makefile b/sys/pic32/mmb-mx7/Makefile index 4f41310..002184e 100644 --- a/sys/pic32/mmb-mx7/Makefile +++ b/sys/pic32/mmb-mx7/Makefile @@ -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 diff --git a/sys/pic32/picadillo/Config b/sys/pic32/picadillo/Config index f6e8c6f..fac6280 100644 --- a/sys/pic32/picadillo/Config +++ b/sys/pic32/picadillo/Config @@ -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 diff --git a/sys/pic32/picadillo/Config-rambo b/sys/pic32/picadillo/Config-rambo index 01cfd9f..57adc9b 100644 --- a/sys/pic32/picadillo/Config-rambo +++ b/sys/pic32/picadillo/Config-rambo @@ -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 diff --git a/sys/pic32/picadillo/Makefile b/sys/pic32/picadillo/Makefile index d81e929..d731b3e 100644 --- a/sys/pic32/picadillo/Makefile +++ b/sys/pic32/picadillo/Makefile @@ -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 diff --git a/sys/pic32/pinguino-micro/Config b/sys/pic32/pinguino-micro/Config index 14e0de8..483cb60 100644 --- a/sys/pic32/pinguino-micro/Config +++ b/sys/pic32/pinguino-micro/Config @@ -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 diff --git a/sys/pic32/pinguino-micro/Makefile b/sys/pic32/pinguino-micro/Makefile index 9fe96f9..5d2ee59 100644 --- a/sys/pic32/pinguino-micro/Makefile +++ b/sys/pic32/pinguino-micro/Makefile @@ -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 diff --git a/sys/pic32/rd_sd.c b/sys/pic32/rd_sd.c index 61d79d0..a99a824 100644 --- a/sys/pic32/rd_sd.c +++ b/sys/pic32/rd_sd.c @@ -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 + spi_brg(sd_fd[unit],SD0_MHZ * 1000); 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; } diff --git a/sys/pic32/sdxl/Config b/sys/pic32/sdxl/Config index 1ba2f94..bd42beb 100644 --- a/sys/pic32/sdxl/Config +++ b/sys/pic32/sdxl/Config @@ -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 diff --git a/sys/pic32/sdxl/Makefile b/sys/pic32/sdxl/Makefile index a9e4048..c68c77f 100644 --- a/sys/pic32/sdxl/Makefile +++ b/sys/pic32/sdxl/Makefile @@ -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 diff --git a/sys/pic32/starter-kit/Config b/sys/pic32/starter-kit/Config index 0eb84a8..9204e8a 100644 --- a/sys/pic32/starter-kit/Config +++ b/sys/pic32/starter-kit/Config @@ -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 diff --git a/sys/pic32/starter-kit/Makefile b/sys/pic32/starter-kit/Makefile index 376c5fe..4603238 100644 --- a/sys/pic32/starter-kit/Makefile +++ b/sys/pic32/starter-kit/Makefile @@ -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 diff --git a/sys/pic32/ubw32/Config b/sys/pic32/ubw32/Config index 5b45ed9..b9bd513 100644 --- a/sys/pic32/ubw32/Config +++ b/sys/pic32/ubw32/Config @@ -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 diff --git a/sys/pic32/ubw32/Config-uart b/sys/pic32/ubw32/Config-uart index f462424..8ca42a7 100644 --- a/sys/pic32/ubw32/Config-uart +++ b/sys/pic32/ubw32/Config-uart @@ -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 diff --git a/sys/pic32/ubw32/Makefile b/sys/pic32/ubw32/Makefile index 503e607..c6b0959 100644 --- a/sys/pic32/ubw32/Makefile +++ b/sys/pic32/ubw32/Makefile @@ -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 diff --git a/sys/pic32/wf32/Config b/sys/pic32/wf32/Config index 5bc00e2..211c49e 100644 --- a/sys/pic32/wf32/Config +++ b/sys/pic32/wf32/Config @@ -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 diff --git a/sys/pic32/wf32/Makefile b/sys/pic32/wf32/Makefile index 3540338..44455f8 100644 --- a/sys/pic32/wf32/Makefile +++ b/sys/pic32/wf32/Makefile @@ -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