cw1200_sagrad.c 3.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
/*
 * Platform glue data for ST-Ericsson CW1200 driver
 *
 * Copyright (c) 2013, Sagrad, Inc
 * Author: Solomon Peachy <speachy@sagrad.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#include <linux/module.h>
13
#include <linux/platform_data/cw1200_platform.h>
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145

MODULE_AUTHOR("Solomon Peachy <speachy@sagrad.com>");
MODULE_DESCRIPTION("ST-Ericsson CW1200 Platform glue driver");
MODULE_LICENSE("GPL");

/* Define just one of these.  Feel free to customize as needed */
#define SAGRAD_1091_1098_EVK_SDIO
/* #define SAGRAD_1091_1098_EVK_SPI */

#ifdef SAGRAD_1091_1098_EVK_SDIO
#if 0
static struct resource cw1200_href_resources[] = {
	{
		.start = 215,  /* fix me as appropriate */
		.end = 215,    /* ditto */
		.flags = IORESOURCE_IO,
		.name = "cw1200_wlan_reset",
	},
	{
		.start = 216,  /* fix me as appropriate */
		.end = 216,    /* ditto */
		.flags = IORESOURCE_IO,
		.name = "cw1200_wlan_powerup",
	},
	{
		.start = NOMADIK_GPIO_TO_IRQ(216), /* fix me as appropriate */
		.end = NOMADIK_GPIO_TO_IRQ(216),   /* ditto */
		.flags = IORESOURCE_IRQ,
		.name = "cw1200_wlan_irq",
	},
};
#endif

static int cw1200_power_ctrl(const struct cw1200_platform_data_sdio *pdata,
			     bool enable)
{
	/* Control 3v3 and 1v8 to hardware as appropriate */
	/* Note this is not needed if it's controlled elsewhere or always on */

	/* May require delay for power to stabilize */
	return 0;
}

static int cw1200_clk_ctrl(const struct cw1200_platform_data_sdio *pdata,
			   bool enable)
{
	/* Turn CLK_32K off and on as appropriate. */
	/* Note this is not needed if it's always on */

	/* May require delay for clock to stabilize */
	return 0;
}

static struct cw1200_platform_data_sdio cw1200_platform_data = {
	.ref_clk = 38400,
	.have_5ghz = false,
#if 0
	.reset = &cw1200_href_resources[0],
	.powerup = &cw1200_href_resources[1],
	.irq = &cw1200_href_resources[2],
#endif
	.power_ctrl = cw1200_power_ctrl,
	.clk_ctrl = cw1200_clk_ctrl,
/*	.macaddr = ??? */
	.sdd_file = "sdd_sagrad_1091_1098.bin",
};
#endif

#ifdef SAGRAD_1091_1098_EVK_SPI
/* Note that this is an example of integrating into your board support file */
static struct resource cw1200_href_resources[] = {
	{
		.start = GPIO_RF_RESET,
		.end = GPIO_RF_RESET,
		.flags = IORESOURCE_IO,
		.name = "cw1200_wlan_reset",
	},
	{
		.start = GPIO_RF_POWERUP,
		.end = GPIO_RF_POWERUP,
		.flags = IORESOURCE_IO,
		.name = "cw1200_wlan_powerup",
	},
};

static int cw1200_power_ctrl(const struct cw1200_platform_data_spi *pdata,
			     bool enable)
{
	/* Control 3v3 and 1v8 to hardware as appropriate */
	/* Note this is not needed if it's controlled elsewhere or always on */

	/* May require delay for power to stabilize */
	return 0;
}
static int cw1200_clk_ctrl(const struct cw1200_platform_data_spi *pdata,
			   bool enable)
{
	/* Turn CLK_32K off and on as appropriate. */
	/* Note this is not needed if it's always on */

	/* May require delay for clock to stabilize */
	return 0;
}

static struct cw1200_platform_data_spi cw1200_platform_data = {
	.ref_clk = 38400,
	.spi_bits_per_word = 16,
	.reset = &cw1200_href_resources[0],
	.powerup = &cw1200_href_resources[1],
	.power_ctrl = cw1200_power_ctrl,
	.clk_ctrl = cw1200_clk_ctrl,
/*	.macaddr = ??? */
	.sdd_file = "sdd_sagrad_1091_1098.bin",
};
static struct spi_board_info myboard_spi_devices[] __initdata = {
	{
		.modalias = "cw1200_wlan_spi",
		.max_speed_hz = 10000000, /* 52MHz Max */
		.bus_num = 0,
		.irq = WIFI_IRQ,
		.platform_data = &cw1200_platform_data,
		.chip_select = 0,
	},
};
#endif


const void *cw1200_get_platform_data(void)
{
	return &cw1200_platform_data;
}
EXPORT_SYMBOL_GPL(cw1200_get_platform_data);