linux/arch/arm/mach-pxa/icontrol.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0-only
   2/*
   3 * linux/arch/arm/mach-pxa/icontrol.c
   4 *
   5 * Support for the iControl and SafeTcam platforms from TMT Services
   6 * using the Embedian MXM-8x10 Computer on Module
   7 *
   8 * Copyright (C) 2009 TMT Services & Supplies (Pty) Ltd.
   9 *
  10 * 2010-01-21 Hennie van der Merve <hvdmerwe@tmtservies.co.za>
  11 */
  12
  13#include <linux/irq.h>
  14#include <linux/platform_device.h>
  15#include <linux/gpio.h>
  16
  17#include <asm/mach-types.h>
  18#include <asm/mach/arch.h>
  19
  20#include "pxa320.h"
  21#include "mxm8x10.h"
  22
  23#include <linux/spi/spi.h>
  24#include <linux/spi/pxa2xx_spi.h>
  25#include <linux/can/platform/mcp251x.h>
  26#include <linux/regulator/machine.h>
  27
  28#include "generic.h"
  29
  30#define ICONTROL_MCP251x_nCS1   (15)
  31#define ICONTROL_MCP251x_nCS2   (16)
  32#define ICONTROL_MCP251x_nCS3   (17)
  33#define ICONTROL_MCP251x_nCS4   (24)
  34
  35#define ICONTROL_MCP251x_nIRQ1  (74)
  36#define ICONTROL_MCP251x_nIRQ2  (75)
  37#define ICONTROL_MCP251x_nIRQ3  (76)
  38#define ICONTROL_MCP251x_nIRQ4  (77)
  39
  40static struct pxa2xx_spi_chip mcp251x_chip_info1 = {
  41        .tx_threshold   = 8,
  42        .rx_threshold   = 128,
  43        .dma_burst_size = 8,
  44        .timeout        = 235,
  45        .gpio_cs        = ICONTROL_MCP251x_nCS1
  46};
  47
  48static struct pxa2xx_spi_chip mcp251x_chip_info2 = {
  49        .tx_threshold   = 8,
  50        .rx_threshold   = 128,
  51        .dma_burst_size = 8,
  52        .timeout        = 235,
  53        .gpio_cs        = ICONTROL_MCP251x_nCS2
  54};
  55
  56static struct pxa2xx_spi_chip mcp251x_chip_info3 = {
  57        .tx_threshold   = 8,
  58        .rx_threshold   = 128,
  59        .dma_burst_size = 8,
  60        .timeout        = 235,
  61        .gpio_cs        = ICONTROL_MCP251x_nCS3
  62};
  63
  64static struct pxa2xx_spi_chip mcp251x_chip_info4 = {
  65        .tx_threshold   = 8,
  66        .rx_threshold   = 128,
  67        .dma_burst_size = 8,
  68        .timeout        = 235,
  69        .gpio_cs        = ICONTROL_MCP251x_nCS4
  70};
  71
  72static struct mcp251x_platform_data mcp251x_info = {
  73        .oscillator_frequency = 16E6,
  74};
  75
  76static struct spi_board_info mcp251x_board_info[] = {
  77        {
  78                .modalias        = "mcp2515",
  79                .max_speed_hz    = 6500000,
  80                .bus_num         = 3,
  81                .chip_select     = 0,
  82                .platform_data   = &mcp251x_info,
  83                .controller_data = &mcp251x_chip_info1,
  84                .irq             = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ1)
  85        },
  86        {
  87                .modalias        = "mcp2515",
  88                .max_speed_hz    = 6500000,
  89                .bus_num         = 3,
  90                .chip_select     = 1,
  91                .platform_data   = &mcp251x_info,
  92                .controller_data = &mcp251x_chip_info2,
  93                .irq             = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ2)
  94        },
  95        {
  96                .modalias        = "mcp2515",
  97                .max_speed_hz    = 6500000,
  98                .bus_num         = 4,
  99                .chip_select     = 0,
 100                .platform_data   = &mcp251x_info,
 101                .controller_data = &mcp251x_chip_info3,
 102                .irq             = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ3)
 103        },
 104        {
 105                .modalias        = "mcp2515",
 106                .max_speed_hz    = 6500000,
 107                .bus_num         = 4,
 108                .chip_select     = 1,
 109                .platform_data   = &mcp251x_info,
 110                .controller_data = &mcp251x_chip_info4,
 111                .irq             = PXA_GPIO_TO_IRQ(ICONTROL_MCP251x_nIRQ4)
 112        }
 113};
 114
 115static struct pxa2xx_spi_controller pxa_ssp3_spi_master_info = {
 116        .num_chipselect = 2,
 117        .enable_dma     = 1
 118};
 119
 120static struct pxa2xx_spi_controller pxa_ssp4_spi_master_info = {
 121        .num_chipselect = 2,
 122        .enable_dma     = 1
 123};
 124
 125struct platform_device pxa_spi_ssp3 = {
 126        .name          = "pxa2xx-spi",
 127        .id            = 3,
 128        .dev           = {
 129                .platform_data = &pxa_ssp3_spi_master_info,
 130        }
 131};
 132
 133struct platform_device pxa_spi_ssp4 = {
 134        .name          = "pxa2xx-spi",
 135        .id            = 4,
 136        .dev           = {
 137                .platform_data = &pxa_ssp4_spi_master_info,
 138        }
 139};
 140
 141static struct platform_device *icontrol_spi_devices[] __initdata = {
 142        &pxa_spi_ssp3,
 143        &pxa_spi_ssp4,
 144};
 145
 146static mfp_cfg_t mfp_can_cfg[] __initdata = {
 147        /* CAN CS lines */
 148        GPIO15_GPIO,
 149        GPIO16_GPIO,
 150        GPIO17_GPIO,
 151        GPIO24_GPIO,
 152
 153        /* SPI (SSP3) lines */
 154        GPIO89_SSP3_SCLK,
 155        GPIO91_SSP3_TXD,
 156        GPIO92_SSP3_RXD,
 157
 158        /* SPI (SSP4) lines */
 159        GPIO93_SSP4_SCLK,
 160        GPIO95_SSP4_TXD,
 161        GPIO96_SSP4_RXD,
 162
 163        /* CAN nIRQ lines */
 164        GPIO74_GPIO | MFP_LPM_EDGE_RISE,
 165        GPIO75_GPIO | MFP_LPM_EDGE_RISE,
 166        GPIO76_GPIO | MFP_LPM_EDGE_RISE,
 167        GPIO77_GPIO | MFP_LPM_EDGE_RISE
 168};
 169
 170static void __init icontrol_can_init(void)
 171{
 172        pxa3xx_mfp_config(ARRAY_AND_SIZE(mfp_can_cfg));
 173        platform_add_devices(ARRAY_AND_SIZE(icontrol_spi_devices));
 174        spi_register_board_info(ARRAY_AND_SIZE(mcp251x_board_info));
 175}
 176
 177static void __init icontrol_init(void)
 178{
 179        mxm_8x10_barebones_init();
 180        mxm_8x10_usb_host_init();
 181        mxm_8x10_mmc_init();
 182
 183        icontrol_can_init();
 184
 185        regulator_has_full_constraints();
 186}
 187
 188MACHINE_START(ICONTROL, "iControl/SafeTcam boards using Embedian MXM-8x10 CoM")
 189        .atag_offset    = 0x100,
 190        .map_io         = pxa3xx_map_io,
 191        .nr_irqs        = PXA_NR_IRQS,
 192        .init_irq       = pxa3xx_init_irq,
 193        .handle_irq     = pxa3xx_handle_irq,
 194        .init_time      = pxa_timer_init,
 195        .init_machine   = icontrol_init,
 196        .restart        = pxa_restart,
 197MACHINE_END
 198