#
# Generic kernel configuration for PIC32 processor.
#
# This file contains all the devices and all the options available
# for the pic32 platform.  It's not expected to be buildable, as some
# devices and options are mutually exclusive or incompatible.
# It's intended to be used as a reference or as a starting point
# when creating configuration for a new board.
#
# For details, see http://retrobsd.org/wiki/doku.php/doc/kconfig
#
architecture    "pic32"
cpu             "PIC32MX7"                  # Processor variant
board           "CHIPKIT_MAX32"             # Board type

# Linker script
ldscript        "max32/bootloader.ld"

# Need to set locally
timezone        8 dst
maxusers        2

# Standard system options
options         "HZ=100"                    # Rate of clock interrupt
options         "CPU_KHZ=80000"             # Oscillator frequency of CPU core
options         "BUS_KHZ=80000"             # Frequency of peripheral bus
options         "BUS_DIV=1"                 # Bus clock divisor 1/2/4/8
options         "EXEC_AOUT"                 # Run a.out binaries
options         "EXEC_ELF"                  # Run ELF binaries
options         "EXEC_SCRIPT"               # Run shell scripts
options         "UCB_METER"                 # Collect kernel statistics
options         "NPROC=10"                  # Number of processes, default 10
options         "NBUF=10"                   # Number of i/o buffers, default 10
options         "NFILE=24"                  # Number of files, default 24
options         "NINODE=24"                 # Number of i-nodes, default 24
options         "NMOUNT=2"                  # Number of mounted filesystems, default 2
options         "SMAPSIZ=NPROC"             # Size of swap map, default NPROC
options         "HALTREBOOT"                # Reboot the processor on halt()
options         "KERNEL_HIGHLIGHT"          # Highlight kernel messages

# LEDs
signal          "LED_DISK"   pin RF0 invert # disk activity indicator
signal          "LED_SWAP"   pin RA1 invert # swap activity indicator
signal          "LED_TTY"    pin RA2 invert # tty activity indicator
signal          "LED_KERNEL" pin RA3 invert # kernel activity indicator

# Root filesystem at /dev/sd0a, swap at /dev/sd0b
config          unix    root on sd0a
                        swap on sd0b
                        dumps on sd0b

# Serial UART ports
device          uart1                       # Serial-to-USB converter
device          uart2
device          uart3
device          uart4
options         "UART_BAUD=115200"          # default speed
signal          "UART4_ENA"     pin RB13    # power enable signal

# USB UART ports
device          uartusb                     # USB device mode, CDC function
options         "UARTUSB_BAUD=115200"       # default speed
options         "USB_AUTOBOOT=YES"          # don't wait for <Enter> on boot
options         "USB_MAX_EP_NUMBER=3"       # parameters of USB device...
options         "USB_NUM_STRING_DESCRIPTORS=3" # ...specific for CDC function

# Console options
options         "CONS_MAJOR=UART_MAJOR"     # use UART device as console
options         "CONS_MINOR=0"              # uart1 is /dev/tty0

# SPI ports
controller      spi2                        # SD card

# microSD card
device          sd0     at spi2 pin RC14    # select pin
options         "SD_MHZ=10"                 # speed 10 MHz
signal          "SD0_ENA"       pin RA5     # SD card enable signal

# General purpose I/O ports
# Flags define a mask of available pins
# For 64-pin devices:
device          gpio1   flags 0xffff    # port B
device          gpio2   flags 0xf000    # port C
device          gpio3   flags 0x0fff    # port D
device          gpio4   flags 0x00ff    # port E
device          gpio5   flags 0x003b    # port F
device          gpio6   flags 0x03cc    # port G

# For 100-pin devices:
device          gpio0   flags 0xc6ff    # port A
device          gpio1   flags 0xffff    # port B
device          gpio2   flags 0xf01e    # port C
device          gpio3   flags 0xffff    # port D
device          gpio4   flags 0x03ff    # port E
device          gpio5   flags 0x313f    # port F
device          gpio6   flags 0xf3cf    # port G

signal          "GPIO_CLEAR"    pin RA5     # clear on startup

# ADC driver
device          adc

# PWM driver
device          pwm

# GLCD driver
device          glcd

# HX8357 driver
device          hxtft

# Skeleton driver
device          skel

# Pseudo terminals
service         pty     4

# System log
service         log

# Power control
device          power
signal          "POWER_LED"     pin RA3
signal          "POWER_SWITCH"  pin RA4
signal          "POWER_CONTROL" pin RA5

# picga
controller      spi1                        # RAM disk: picga
device          picga0  at spi1 pin RA4     # chip select signal
options         "PICGA_BUS=SPI1CON"         # TODO: delete this option
signal          "PICGA_CS" pin RA4          # TODO: delete

#--------------------------------------------
# Custom RAM disk devices
#

# sdramp - SDRAM block device
# The volume is divided into two partitions: A and B.
# Size of partition B is specified as option SDR_SWAP_KBYTES.
# The rest is partition A.
device          dr0                         # SDRAM on external memory bus
options         "SDR_SWAP_KBYTES=2048"      # size of partition B
options         "KERNEL_EXECUTABLE_RAM"     # allow kernel code in RAM area

# sramc - SRAM block device
# The volume is divided into two partitions: A and B.
# Size of partition B is specified as option SRAMC_SWAP_KBYTES.
# The rest is partition A.
device          rc0                         # SRAM via 4-wire CPLD interface
signal          "SRAMC_DATA"    pin RE0
signal          "SRAMC_LDA"     pin RC13
signal          "SRAMC_RD"      pin RF1
signal          "SRAMC_WR"      pin RF0
options         "SRAMC_SWAP_KBYTES=2048"    # size of partition B

# mrams - SPI block device
controller      spi1                        # RAM disk: mrams
device          mr0  at spi1
                pins RA4, RA2, RB14, RB12   # chip select signals
options         "MRAMS_CHIPS=4"             # number of chips
options         "MRAMS_CHIPSIZE=512"        # chip size in kbytes
options         "MRAMS_MHZ=10"              # speed 10 MHz
signal          "MRAMS_LED0"    pin RF0     # optional LED indicators
signal          "MRAMS_LED1"    pin RF1
signal          "MRAMS_LED2"    pin RF2
signal          "MRAMS_LED3"    pin RF3

# spirams - SPI block device
controller      spi1                        # RAM disk: spirams
device          sr0  at spi1
                pins RF0,  RF1,  RF2,  RF3, # chip select signals
                     RF4,  RF5,  RF6,  RF7,
                     RF8,  RF9,  RF10, RF11,
                     RF12, RF13, RF14, RF15
options         "SPIRAMS_CHIPSIZE=128"      # chip size in kbytes
options         "SPIRAMS_CHIPS=16"          # number of chips
options         "SPIRAMS_MHZ=10"            # speed 10 MHz
signal          "SPIRAMS_LED0"  pin RG0     # optional LED indicators
signal          "SPIRAMS_LED1"  pin RG1
signal          "SPIRAMS_LED2"  pin RG2
signal          "SPIRAMS_LED3"  pin RG3
signal          "SPIRAMS_LED4"  pin RG4
signal          "SPIRAMS_LED5"  pin RG5
signal          "SPIRAMS_LED6"  pin RG6
signal          "SPIRAMS_LED7"  pin RG7
signal          "SPIRAMS_LED8"  pin RG8
signal          "SPIRAMS_LED9"  pin RG9
signal          "SPIRAMS_LED10" pin RG10
signal          "SPIRAMS_LED11" pin RG11
signal          "SPIRAMS_LED12" pin RG12
signal          "SPIRAMS_LED13" pin RG13
signal          "SPIRAMS_LED14" pin RG14
signal          "SPIRAMS_LED15" pin RG15
