diff options
Diffstat (limited to 'arch/arm/mach-exynos/board-m0ctc-modems.c')
-rw-r--r-- | arch/arm/mach-exynos/board-m0ctc-modems.c | 2224 |
1 files changed, 1339 insertions, 885 deletions
diff --git a/arch/arm/mach-exynos/board-m0ctc-modems.c b/arch/arm/mach-exynos/board-m0ctc-modems.c index 3f69c69..27dbf6e 100644 --- a/arch/arm/mach-exynos/board-m0ctc-modems.c +++ b/arch/arm/mach-exynos/board-m0ctc-modems.c @@ -1,4 +1,4 @@ -/* linux/arch/arm/mach-xxxx/board-c1ctc-modems.c +/* linux/arch/arm/mach-xxxx/board-m0ctc-modems.c * Copyright (C) 2010 Samsung Electronics. All rights reserved. * * This software is licensed under the terms of the GNU General Public @@ -42,9 +42,19 @@ #include <plat/devs.h> #include <plat/ehci.h> +#if defined(CONFIG_LINK_DEVICE_PLD) +#include <linux/spi/spi.h> +#include <mach/pld_pdata.h> +#endif + #define SROM_CS0_BASE 0x04000000 #define SROM_WIDTH 0x01000000 + +#if defined(CONFIG_LINK_DEVICE_PLD) +#define SROM_NUM_ADDR_BITS 15 +#else #define SROM_NUM_ADDR_BITS 14 +#endif /* * For SROMC Configuration: @@ -58,6 +68,7 @@ /* Memory attributes */ enum sromc_attr { + MEM_DATA_BUS_8BIT = 0x00000000, MEM_DATA_BUS_16BIT = 0x00000001, MEM_BYTE_ADDRESSABLE = 0x00000002, MEM_WAIT_EN = 0x00000004, @@ -86,7 +97,11 @@ struct sromc_access_cfg { }; /* For MDM6600 EDPRAM (External DPRAM) */ +#if defined(CONFIG_LINK_DEVICE_PLD) +#define MSM_EDPRAM_SIZE 0x10000 /* 8 KB */ +#else #define MSM_EDPRAM_SIZE 0x4000 /* 16 KB */ +#endif #define INT_MASK_REQ_ACK_F 0x0020 #define INT_MASK_REQ_ACK_R 0x0010 @@ -104,7 +119,6 @@ static void config_dpram_port_gpio(void); static void init_sromc(void); static void setup_sromc(unsigned csn, struct sromc_cfg *cfg, struct sromc_access_cfg *acc_cfg); -static void setup_dpram_speed(unsigned csn, struct sromc_access_cfg *acc_cfg); static int __init init_modem(void); #ifdef CONFIG_USBHUB_USB3503 @@ -116,23 +130,45 @@ static int host_port_enable(int port, int enable) } #endif +#if defined(CONFIG_LINK_DEVICE_PLD) +static struct sromc_cfg msm_edpram_cfg = { + .attr = (MEM_DATA_BUS_8BIT), + .size = 0x10000, +}; +#else static struct sromc_cfg msm_edpram_cfg = { .attr = (MEM_DATA_BUS_16BIT | MEM_WAIT_EN | MEM_BYTE_EN), .size = MSM_EDPRAM_SIZE, }; +#endif +#if defined(CONFIG_LINK_DEVICE_PLD) +static struct sromc_access_cfg msm_edpram_access_cfg[] = { + [DPRAM_SPEED_LOW] = { + .tacs = 0x2 << 28, + .tcos = 0x2 << 24, + .tacc = 0x3 << 16, + .tcoh = 0x2 << 12, + .tcah = 0x2 << 8, + .tacp = 0x3 << 4, + .pmc = 0x0 << 0, + }, +}; +#else static struct sromc_access_cfg msm_edpram_access_cfg[] = { [DPRAM_SPEED_LOW] = { - .tacs = 0x2 << 28, - .tcos = 0x2 << 24, - .tacc = 0x3 << 16, - .tcoh = 0x2 << 12, - .tcah = 0x2 << 8, - .tacp = 0x2 << 4, - .pmc = 0x0 << 0, - }, + .tacs = 0x2 << 28, + .tcos = 0x2 << 24, + .tacc = 0x3 << 16, + .tcoh = 0x2 << 12, + .tcah = 0x2 << 8, + .tacp = 0x2 << 4, + .pmc = 0x0 << 0, + }, }; +#endif +#if (MSM_EDPRAM_SIZE == 0x4000) /* magic_code + access_enable + @@ -187,23 +223,7 @@ struct msm_edpram_ipc_cfg { u16 mbx_cp2ap; }; -struct msm_edpram_boot_map { - u8 __iomem *buff; - u16 __iomem *frame_size; - u16 __iomem *tag; - u16 __iomem *count; -}; - -static struct dpram_ipc_map msm_ipc_map; - -struct _param_nv { - unsigned char *addr; - unsigned int size; - unsigned int count; - unsigned int tag; -}; -#if (MSM_EDPRAM_SIZE == 0x4000) /* ------------------ Buffer : 15KByte @@ -223,11 +243,85 @@ CP -> AP Intr : 2Byte */ #define DP_BOOT_CLEAR_OFFSET 4 #define DP_BOOT_RSRVD_OFFSET 0x3C00 -#define DP_BOOT_SIZE_OFFSET 0x3FF6 -#define DP_BOOT_TAG_OFFSET 0x3FF8 +#define DP_BOOT_SIZE_OFFSET 0x3FF6 +#define DP_BOOT_TAG_OFFSET 0x3FF8 #define DP_BOOT_COUNT_OFFSET 0x3FFA #define DP_BOOT_FRAME_SIZE_LIMIT 0x3C00 /* 15KB = 15360byte = 0x3C00 */ + +#elif (MSM_EDPRAM_SIZE == 0x10000) + +/* + mbx_ap2cp + 0x0 + magic_code + + access_enable + + padding + + mbx_cp2ap + 0x1000 + magic_code + + access_enable + + padding + + fmt_tx_head + fmt_tx_tail + fmt_tx_buff + 0x2000 + raw_tx_head + raw_tx_tail + raw_tx_buff + + fmt_rx_head + fmt_rx_tail + fmt_rx_buff + 0x3000 + raw_rx_head + raw_rx_tail + raw_rx_buff + + = 2 + + 4094 + + 2 + + 4094 + + 2 + + 2 + + 2 + 2 + 1020 + + 2 + 2 + 3064 + + 2 + 2 + 1020 + + 2 + 2 + 3064 + */ + +#define MSM_DP_FMT_TX_BUFF_SZ 1024 +#define MSM_DP_RAW_TX_BUFF_SZ 3072 +#define MSM_DP_FMT_RX_BUFF_SZ 1024 +#define MSM_DP_RAW_RX_BUFF_SZ 3072 + +#define MAX_MSM_EDPRAM_IPC_DEV 2 /* FMT, RAW */ + +struct msm_edpram_ipc_cfg { + u16 mbx_ap2cp; + u16 magic_ap2cp; + u16 access_ap2cp; + u16 fmt_tx_head; + u16 raw_tx_head; + u16 fmt_rx_tail; + u16 raw_rx_tail; + u16 temp1; + u8 padding1[4080]; + + u16 mbx_cp2ap; + u16 magic_cp2ap; + u16 access_cp2ap; + u16 fmt_tx_tail; + u16 raw_tx_tail; + u16 fmt_rx_head; + u16 raw_rx_head; + u16 temp2; + u8 padding2[4080]; + + u8 fmt_tx_buff[MSM_DP_FMT_TX_BUFF_SZ]; + u8 raw_tx_buff[MSM_DP_RAW_TX_BUFF_SZ]; + u8 fmt_rx_buff[MSM_DP_FMT_RX_BUFF_SZ]; + u8 raw_rx_buff[MSM_DP_RAW_RX_BUFF_SZ]; + + u8 padding3[16384]; + + u16 address_buffer; +}; + +#define DP_BOOT_CLEAR_OFFSET 0 +#define DP_BOOT_RSRVD_OFFSET 0 +#define DP_BOOT_SIZE_OFFSET 0x2 +#define DP_BOOT_TAG_OFFSET 0x4 +#define DP_BOOT_COUNT_OFFSET 0x6 + +#define DP_BOOT_FRAME_SIZE_LIMIT 0x1000 /* 15KB = 15360byte = 0x3C00 */ + #else /* ------------------ @@ -248,286 +342,339 @@ CP -> AP Intr : 2Byte */ #define DP_BOOT_CLEAR_OFFSET 4 #define DP_BOOT_RSRVD_OFFSET 0x7C00 -#define DP_BOOT_SIZE_OFFSET 0x7FF6 -#define DP_BOOT_TAG_OFFSET 0x7FF8 +#define DP_BOOT_SIZE_OFFSET 0x7FF6 +#define DP_BOOT_TAG_OFFSET 0x7FF8 #define DP_BOOT_COUNT_OFFSET 0x7FFA #define DP_BOOT_FRAME_SIZE_LIMIT 0x7C00 /* 31KB = 31744byte = 0x7C00 */ #endif -struct _param_check { - unsigned int total_size; - unsigned int rest_size; - unsigned int send_size; - unsigned int copy_start; - unsigned int copy_complete; - unsigned int boot_complete; -}; - -static struct _param_nv *data_param; -static struct _param_check check_param; - -static unsigned int boot_start_complete; -static struct msm_edpram_boot_map msm_edpram_bt_map; static struct dpram_ipc_map msm_ipc_map; -static unsigned char *img; -static unsigned char *nv_img; - -static void msm_edpram_reset(void); -static void msm_edpram_clr_intr(void); -static u16 msm_edpram_recv_intr(void); -static void msm_edpram_send_intr(u16 irq_mask); -static u16 msm_edpram_recv_msg(void); -static void msm_edpram_send_msg(u16 msg); - -static u16 msm_edpram_get_magic(void); -static void msm_edpram_set_magic(u16 value); -static u16 msm_edpram_get_access(void); -static void msm_edpram_set_access(u16 value); - -static u32 msm_edpram_get_tx_head(int dev_id); -static u32 msm_edpram_get_tx_tail(int dev_id); -static void msm_edpram_set_tx_head(int dev_id, u32 head); -static void msm_edpram_set_tx_tail(int dev_id, u32 tail); -static u8 __iomem *msm_edpram_get_tx_buff(int dev_id); -static u32 msm_edpram_get_tx_buff_size(int dev_id); - -static u32 msm_edpram_get_rx_head(int dev_id); -static u32 msm_edpram_get_rx_tail(int dev_id); -static void msm_edpram_set_rx_head(int dev_id, u32 head); -static void msm_edpram_set_rx_tail(int dev_id, u32 tail); -static u8 __iomem *msm_edpram_get_rx_buff(int dev_id); -static u32 msm_edpram_get_rx_buff_size(int dev_id); - -static u16 msm_edpram_get_mask_req_ack(int dev_id); -static u16 msm_edpram_get_mask_res_ack(int dev_id); -static u16 msm_edpram_get_mask_send(int dev_id); - -static void msm_log_disp(struct modemlink_dpram_control *dpctl); -static int msm_uload_step1(struct modemlink_dpram_control *dpctl); -static int msm_uload_step2(void *arg, struct modemlink_dpram_control *dpctl); -static int msm_dload_prep(struct modemlink_dpram_control *dpctl); -static int msm_dload(void *arg, struct modemlink_dpram_control *dpctl); -static int msm_nv_load(void *arg, struct modemlink_dpram_control *dpctl); -static int msm_boot_start(struct modemlink_dpram_control *dpctl); -static int msm_boot_start_post_proc(void); -static void msm_boot_start_handler(struct modemlink_dpram_control *dpctl); -static void msm_dload_handler(struct modemlink_dpram_control *dpctl, u16 cmd); -static void msm_bt_map_init(struct modemlink_dpram_control *dpctl); -static void msm_load_init(struct modemlink_dpram_control *dpctl); -static void msm_terminate_link(struct modemlink_dpram_control *dpctl); - static struct modemlink_dpram_control msm_edpram_ctrl = { - .reset = msm_edpram_reset, - - .clear_intr = msm_edpram_clr_intr, - .recv_intr = msm_edpram_recv_intr, - .send_intr = msm_edpram_send_intr, - .recv_msg = msm_edpram_recv_msg, - .send_msg = msm_edpram_send_msg, - - .get_magic = msm_edpram_get_magic, - .set_magic = msm_edpram_set_magic, - .get_access = msm_edpram_get_access, - .set_access = msm_edpram_set_access, - - .get_tx_head = msm_edpram_get_tx_head, - .get_tx_tail = msm_edpram_get_tx_tail, - .set_tx_head = msm_edpram_set_tx_head, - .set_tx_tail = msm_edpram_set_tx_tail, - .get_tx_buff = msm_edpram_get_tx_buff, - .get_tx_buff_size = msm_edpram_get_tx_buff_size, - - .get_rx_head = msm_edpram_get_rx_head, - .get_rx_tail = msm_edpram_get_rx_tail, - .set_rx_head = msm_edpram_set_rx_head, - .set_rx_tail = msm_edpram_set_rx_tail, - .get_rx_buff = msm_edpram_get_rx_buff, - .get_rx_buff_size = msm_edpram_get_rx_buff_size, - - .get_mask_req_ack = msm_edpram_get_mask_req_ack, - .get_mask_res_ack = msm_edpram_get_mask_res_ack, - .get_mask_send = msm_edpram_get_mask_send, - - .log_disp = msm_log_disp, - .cpupload_step1 = msm_uload_step1, - .cpupload_step2 = msm_uload_step2, - .cpimage_load = msm_dload, - .nvdata_load = msm_nv_load, - .phone_boot_start = msm_boot_start, - .dload_cmd_hdlr = msm_dload_handler, - .bt_map_init = msm_bt_map_init, - .load_init = msm_load_init, - .cpimage_load_prepare = msm_dload_prep, - .phone_boot_start_post_process = msm_boot_start_post_proc, - .phone_boot_start_handler = msm_boot_start_handler, - .terminate_link = msm_terminate_link, - - .dp_base = NULL, - .dp_size = 0, .dp_type = EXT_DPRAM, .dpram_irq = MSM_DPRAM_INT_IRQ, .dpram_irq_flags = IRQF_TRIGGER_FALLING, - .dpram_irq_name = "MDM6600_EDPRAM_IRQ", - .dpram_wlock_name = "MDM6600_EDPRAM_WLOCK", .max_ipc_dev = IPC_RFS, + .ipc_map = &msm_ipc_map, + + .boot_size_offset = DP_BOOT_SIZE_OFFSET, + .boot_tag_offset = DP_BOOT_TAG_OFFSET, + .boot_count_offset = DP_BOOT_COUNT_OFFSET, + .max_boot_frame_size = DP_BOOT_FRAME_SIZE_LIMIT, + +#if defined(CONFIG_LINK_DEVICE_PLD) + .aligned = 1, +#endif }; /* ** CDMA target platform data */ +#if defined(CONFIG_LINK_DEVICE_PLD) +static struct modem_io_t cdma_io_devices[] = { + [0] = { + .name = "cdma_boot0", + .id = 0x1, + .format = IPC_BOOT, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_PLD) + }, + [1] = { + .name = "cdma_ramdump0", + .id = 0x1, + .format = IPC_RAMDUMP, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_PLD), + }, + [2] = { + .name = "umts_ipc0", + .id = 0x01, + .format = IPC_FMT, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_PLD), + }, + [3] = { + .name = "cdma_ipc0", + .id = 0x00, + .format = IPC_FMT, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_PLD), + }, + [4] = { + .name = "multi_pdp", + .id = 0x1, + .format = IPC_MULTI_RAW, + .io_type = IODEV_DUMMY, + .links = LINKTYPE(LINKDEV_PLD), + }, + [5] = { + .name = "cdma_CSD", + .id = (1 | 0x20), + .format = IPC_RAW, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_PLD), + }, + [6] = { + .name = "cdma_FOTA", + .id = (2 | 0x20), + .format = IPC_RAW, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_PLD), + }, + [7] = { + .name = "cdma_GPS", + .id = (5 | 0x20), + .format = IPC_RAW, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_PLD), + }, + [8] = { + .name = "cdma_XTRA", + .id = (6 | 0x20), + .format = IPC_RAW, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_PLD), + }, + [9] = { + .name = "cdma_CDMA", + .id = (7 | 0x20), + .format = IPC_RAW, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_PLD), + }, + [10] = { + .name = "cdma_EFS", + .id = (8 | 0x20), + .format = IPC_RAW, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_PLD), + }, + [11] = { + .name = "cdma_TRFB", + .id = (9 | 0x20), + .format = IPC_RAW, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_PLD), + }, + [12] = { + .name = "rmnet0", + .id = 0x2A, + .format = IPC_RAW, + .io_type = IODEV_NET, + .links = LINKTYPE(LINKDEV_PLD), + }, + [13] = { + .name = "rmnet1", + .id = 0x2B, + .format = IPC_RAW, + .io_type = IODEV_NET, + .links = LINKTYPE(LINKDEV_PLD), + }, + [14] = { + .name = "rmnet2", + .id = 0x2C, + .format = IPC_RAW, + .io_type = IODEV_NET, + .links = LINKTYPE(LINKDEV_PLD), + }, + [15] = { + .name = "rmnet3", + .id = 0x2D, + .format = IPC_RAW, + .io_type = IODEV_NET, + .links = LINKTYPE(LINKDEV_PLD), + }, + [16] = { + .name = "cdma_SMD", + .id = (25 | 0x20), + .format = IPC_RAW, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_PLD), + }, + [17] = { + .name = "cdma_VTVD", + .id = (26 | 0x20), + .format = IPC_RAW, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_PLD), + }, + [18] = { + .name = "cdma_VTAD", + .id = (27 | 0x20), + .format = IPC_RAW, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_PLD), + }, + [19] = { + .name = "cdma_VTCTRL", + .id = (28 | 0x20), + .format = IPC_RAW, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_PLD), + }, + [20] = { + .name = "cdma_VTENT", + .id = (29 | 0x20), + .format = IPC_RAW, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_PLD), + }, +}; + +#else static struct modem_io_t cdma_io_devices[] = { [0] = { - .name = "cdma_boot0", - .id = 0x1, - .format = IPC_BOOT, - .io_type = IODEV_MISC, - .links = LINKTYPE(LINKDEV_DPRAM), - }, + .name = "cdma_boot0", + .id = 0x1, + .format = IPC_BOOT, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_DPRAM), + }, [1] = { - .name = "cdma_ramdump0", - .id = 0x1, - .format = IPC_RAMDUMP, - .io_type = IODEV_MISC, - .links = LINKTYPE(LINKDEV_DPRAM), - }, + .name = "cdma_ramdump0", + .id = 0x1, + .format = IPC_RAMDUMP, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_DPRAM), + }, [2] = { - .name = "umts_ipc0", - .id = 0x01, - .format = IPC_FMT, - .io_type = IODEV_MISC, - .links = LINKTYPE(LINKDEV_DPRAM), - }, + .name = "umts_ipc0", + .id = 0x01, + .format = IPC_FMT, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_DPRAM), + }, [3] = { - .name = "cdma_ipc0", - .id = 0x00, - .format = IPC_FMT, - .io_type = IODEV_MISC, - .links = LINKTYPE(LINKDEV_DPRAM), - }, + .name = "cdma_ipc0", + .id = 0x00, + .format = IPC_FMT, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_DPRAM), + }, [4] = { - .name = "multi_pdp", - .id = 0x1, - .format = IPC_MULTI_RAW, - .io_type = IODEV_DUMMY, - .links = LINKTYPE(LINKDEV_DPRAM), - }, + .name = "multi_pdp", + .id = 0x1, + .format = IPC_MULTI_RAW, + .io_type = IODEV_DUMMY, + .links = LINKTYPE(LINKDEV_DPRAM), + }, [5] = { - .name = "cdma_CSD", - .id = (1 | 0x20), - .format = IPC_RAW, - .io_type = IODEV_MISC, - .links = LINKTYPE(LINKDEV_DPRAM), - }, + .name = "cdma_CSD", + .id = (1 | 0x20), + .format = IPC_RAW, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_DPRAM), + }, [6] = { - .name = "cdma_FOTA", - .id = (2 | 0x20), - .format = IPC_RAW, - .io_type = IODEV_MISC, - .links = LINKTYPE(LINKDEV_DPRAM), - }, + .name = "cdma_FOTA", + .id = (2 | 0x20), + .format = IPC_RAW, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_DPRAM), + }, [7] = { - .name = "cdma_GPS", - .id = (5 | 0x20), - .format = IPC_RAW, - .io_type = IODEV_MISC, - .links = LINKTYPE(LINKDEV_DPRAM), - }, + .name = "cdma_GPS", + .id = (5 | 0x20), + .format = IPC_RAW, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_DPRAM), + }, [8] = { - .name = "cdma_XTRA", - .id = (6 | 0x20), - .format = IPC_RAW, - .io_type = IODEV_MISC, - .links = LINKTYPE(LINKDEV_DPRAM), - }, + .name = "cdma_XTRA", + .id = (6 | 0x20), + .format = IPC_RAW, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_DPRAM), + }, [9] = { - .name = "cdma_CDMA", - .id = (7 | 0x20), - .format = IPC_RAW, - .io_type = IODEV_MISC, - .links = LINKTYPE(LINKDEV_DPRAM), - }, + .name = "cdma_CDMA", + .id = (7 | 0x20), + .format = IPC_RAW, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_DPRAM), + }, [10] = { .name = "cdma_EFS", .id = (8 | 0x20), .format = IPC_RAW, .io_type = IODEV_MISC, .links = LINKTYPE(LINKDEV_DPRAM), - }, + }, [11] = { .name = "cdma_TRFB", .id = (9 | 0x20), .format = IPC_RAW, .io_type = IODEV_MISC, .links = LINKTYPE(LINKDEV_DPRAM), - }, + }, [12] = { .name = "rmnet0", .id = 0x2A, .format = IPC_RAW, .io_type = IODEV_NET, .links = LINKTYPE(LINKDEV_DPRAM), - }, + }, [13] = { .name = "rmnet1", .id = 0x2B, .format = IPC_RAW, .io_type = IODEV_NET, .links = LINKTYPE(LINKDEV_DPRAM), - }, + }, [14] = { .name = "rmnet2", .id = 0x2C, .format = IPC_RAW, .io_type = IODEV_NET, .links = LINKTYPE(LINKDEV_DPRAM), - }, + }, [15] = { .name = "rmnet3", .id = 0x2D, .format = IPC_RAW, .io_type = IODEV_NET, .links = LINKTYPE(LINKDEV_DPRAM), - }, + }, [16] = { .name = "cdma_SMD", .id = (25 | 0x20), .format = IPC_RAW, .io_type = IODEV_MISC, .links = LINKTYPE(LINKDEV_DPRAM), - }, + }, [17] = { .name = "cdma_VTVD", .id = (26 | 0x20), .format = IPC_RAW, .io_type = IODEV_MISC, .links = LINKTYPE(LINKDEV_DPRAM), - }, + }, [18] = { .name = "cdma_VTAD", .id = (27 | 0x20), .format = IPC_RAW, .io_type = IODEV_MISC, .links = LINKTYPE(LINKDEV_DPRAM), - }, + }, [19] = { .name = "cdma_VTCTRL", .id = (28 | 0x20), .format = IPC_RAW, .io_type = IODEV_MISC, .links = LINKTYPE(LINKDEV_DPRAM), - }, + }, [20] = { .name = "cdma_VTENT", .id = (29 | 0x20), .format = IPC_RAW, .io_type = IODEV_MISC, .links = LINKTYPE(LINKDEV_DPRAM), - }, + }, }; +#endif static struct modem_data cdma_modem_data = { .name = "mdm6600", @@ -539,21 +686,37 @@ static struct modem_data cdma_modem_data = { .gpio_pda_active = GPIO_PDA_ACTIVE, .gpio_phone_active = GPIO_MSM_PHONE_ACTIVE, .gpio_flm_uart_sel = GPIO_BOOT_SW_SEL, -#if 1 +#if defined(CONFIG_MACH_M0_CTC) .gpio_flm_uart_sel_rev06 = GPIO_BOOT_SW_SEL_REV06, + .gpio_host_wakeup = GPIO_IPC_HOST_WAKEUP, #endif .gpio_dpram_int = GPIO_MSM_DPRAM_INT, - .gpio_host_wakeup = GPIO_IPC_HOST_WAKEUP, - - .gpio_cp_dump_int = 0, + .gpio_cp_dump_int = GPIO_CP_DUMP_INT, .gpio_cp_warm_reset = 0, .use_handover = false, +#if defined(CONFIG_SIM_DETECT) + .gpio_sim_detect = GPIO_CP_SIM_DETECT, +#else + .gpio_sim_detect = 0, +#endif + +#if defined(CONFIG_LINK_DEVICE_PLD) + .gpio_fpga2_creset = GPIO_FPGA2_CRESET, + .gpio_fpga2_cdone = GPIO_FPGA2_CDONE, + .gpio_fpga2_rst_n = GPIO_FPGA2_RST_N, + .gpio_fpga2_cs_n = GPIO_FPGA2_CS_N, +#endif + .modem_net = CDMA_NETWORK, .modem_type = QC_MDM6600, +#if defined(CONFIG_LINK_DEVICE_PLD) + .link_types = LINKTYPE(LINKDEV_PLD), +#else .link_types = LINKTYPE(LINKDEV_DPRAM), +#endif .link_name = "mdm6600_edpram", .dpram_ctl = &msm_edpram_ctrl, @@ -565,11 +728,25 @@ static struct modem_data cdma_modem_data = { static struct resource cdma_modem_res[] = { [0] = { - .name = "cp_active_irq", - .start = MSM_PHONE_ACTIVE_IRQ, - .end = MSM_PHONE_ACTIVE_IRQ, - .flags = IORESOURCE_IRQ, - }, + .name = "cp_active_irq", + .start = MSM_PHONE_ACTIVE_IRQ, + .end = MSM_PHONE_ACTIVE_IRQ, + .flags = IORESOURCE_IRQ, + }, + [1] = { + .name = "dpram_irq", + .start = MSM_DPRAM_INT_IRQ, + .end = MSM_DPRAM_INT_IRQ, + .flags = IORESOURCE_IRQ, + }, +#if defined(CONFIG_SIM_DETECT) + [2] = { + .name = "sim_irq", + .start = CP_SIM_DETECT_IRQ, + .end = CP_SIM_DETECT_IRQ, + .flags = IORESOURCE_IRQ, + }, +#endif }; static struct platform_device cdma_modem = { @@ -579,614 +756,9 @@ static struct platform_device cdma_modem = { .resource = cdma_modem_res, .dev = { .platform_data = &cdma_modem_data, - }, + }, }; -static void msm_edpram_reset(void) -{ - return; -} - -static void msm_edpram_clr_intr(void) -{ - ioread16(msm_ipc_map.mbx_cp2ap); -} - -static u16 msm_edpram_recv_intr(void) -{ - return ioread16(msm_ipc_map.mbx_cp2ap); -} - -static void msm_edpram_send_intr(u16 irq_mask) -{ - iowrite16(irq_mask, msm_ipc_map.mbx_ap2cp); -} - -static u16 msm_edpram_recv_msg(void) -{ - return ioread16(msm_ipc_map.mbx_cp2ap); -} - -static void msm_edpram_send_msg(u16 msg) -{ - iowrite16(msg, msm_ipc_map.mbx_ap2cp); -} - -static u16 msm_edpram_get_magic(void) -{ - return ioread16(msm_ipc_map.magic); -} - -static void msm_edpram_set_magic(u16 value) -{ - iowrite16(value, msm_ipc_map.magic); -} - -static u16 msm_edpram_get_access(void) -{ - return ioread16(msm_ipc_map.access); -} - -static void msm_edpram_set_access(u16 value) -{ - iowrite16(value, msm_ipc_map.access); -} - -static u32 msm_edpram_get_tx_head(int dev_id) -{ - return ioread16(msm_ipc_map.dev[dev_id].txq.head); -} - -static u32 msm_edpram_get_tx_tail(int dev_id) -{ - return ioread16(msm_ipc_map.dev[dev_id].txq.tail); -} - -static void msm_edpram_set_tx_head(int dev_id, u32 head) -{ - iowrite16((u16) head, msm_ipc_map.dev[dev_id].txq.head); -} - -static void msm_edpram_set_tx_tail(int dev_id, u32 tail) -{ - iowrite16((u16) tail, msm_ipc_map.dev[dev_id].txq.tail); -} - -static u8 __iomem *msm_edpram_get_tx_buff(int dev_id) -{ - return msm_ipc_map.dev[dev_id].txq.buff; -} - -static u32 msm_edpram_get_tx_buff_size(int dev_id) -{ - return msm_ipc_map.dev[dev_id].txq.size; -} - -static u32 msm_edpram_get_rx_head(int dev_id) -{ - return ioread16(msm_ipc_map.dev[dev_id].rxq.head); -} - -static u32 msm_edpram_get_rx_tail(int dev_id) -{ - return ioread16(msm_ipc_map.dev[dev_id].rxq.tail); -} - -static void msm_edpram_set_rx_head(int dev_id, u32 head) -{ - return iowrite16((u16) head, msm_ipc_map.dev[dev_id].rxq.head); -} - -static void msm_edpram_set_rx_tail(int dev_id, u32 tail) -{ - return iowrite16((u16) tail, msm_ipc_map.dev[dev_id].rxq.tail); -} - -static u8 __iomem *msm_edpram_get_rx_buff(int dev_id) -{ - return msm_ipc_map.dev[dev_id].rxq.buff; -} - -static u32 msm_edpram_get_rx_buff_size(int dev_id) -{ - return msm_ipc_map.dev[dev_id].rxq.size; -} - -static u16 msm_edpram_get_mask_req_ack(int dev_id) -{ - return msm_ipc_map.dev[dev_id].mask_req_ack; -} - -static u16 msm_edpram_get_mask_res_ack(int dev_id) -{ - return msm_ipc_map.dev[dev_id].mask_res_ack; -} - -static u16 msm_edpram_get_mask_send(int dev_id) -{ - return msm_ipc_map.dev[dev_id].mask_send; -} - -static void msm_log_disp(struct modemlink_dpram_control *dpctl) -{ - static unsigned char buf[151]; - u8 __iomem *tmp_buff = NULL; - - tmp_buff = dpctl->get_rx_buff(IPC_FMT); - memcpy(buf, tmp_buff, (sizeof(buf) - 1)); - - pr_info("[LNK] | PHONE ERR MSG\t| CDMA Crash\n"); - pr_info("[LNK] | PHONE ERR MSG\t| %s\n", buf); -} - -static int msm_data_upload(struct _param_nv *param, - struct modemlink_dpram_control *dpctl) -{ - int retval = 0; - u16 in_interrupt = 0; - int count = 0; - - while (1) { - if (!gpio_get_value(GPIO_MSM_DPRAM_INT)) { - in_interrupt = dpctl->recv_msg(); - if (in_interrupt == 0xDBAB) { - break; - } else { - pr_err("[LNK][intr]:0x%08x\n", in_interrupt); - pr_err("[LNK/E]<%s:%d>\n", __func__, __LINE__); - return -1; - } - } - msleep_interruptible(1); - count++; - if (count > 200) { - pr_err("[LNK/E]<%s:%d>\n", __func__, __LINE__); - return -1; - } - } - - param->size = ioread16(msm_edpram_bt_map.frame_size); - memcpy(param->addr, msm_edpram_bt_map.buff, param->size); - param->tag = ioread16(msm_edpram_bt_map.tag); - param->count = ioread16(msm_edpram_bt_map.count); - - dpctl->clear_intr(); - dpctl->send_msg(0xDB12); - - return retval; - -} - -static int msm_data_load(struct _param_nv *param, - struct modemlink_dpram_control *dpctl) -{ - int retval = 0; - - if (param->size <= DP_BOOT_FRAME_SIZE_LIMIT) { - memcpy(msm_edpram_bt_map.buff, param->addr, param->size); - iowrite16(param->size, msm_edpram_bt_map.frame_size); - iowrite16(param->tag, msm_edpram_bt_map.tag); - iowrite16(param->count, msm_edpram_bt_map.count); - - dpctl->clear_intr(); - dpctl->send_msg(0xDB12); - - } else { - pr_err("[LNK/E]<%s> size:0x%x\n", __func__, param->size); - } - - return retval; -} - -static int msm_uload_step1(struct modemlink_dpram_control *dpctl) -{ - int retval = 0; - int count = 0; - u16 in_interrupt = 0, out_interrupt = 0; - - pr_info("[LNK] +---------------------------------------------+\n"); - pr_info("[LNK] | UPLOAD PHONE SDRAM |\n"); - pr_info("[LNK] +---------------------------------------------+\n"); - - while (1) { - if (!gpio_get_value(GPIO_MSM_DPRAM_INT)) { - in_interrupt = dpctl->recv_msg(); - pr_info("[LNK] [in_interrupt] 0x%04x\n", in_interrupt); - if (in_interrupt == 0x1234) { - break; - } else { - pr_err("[LNK/E]<%s:%d>\n", __func__, __LINE__); - return -1; - } - } - msleep_interruptible(1); - count++; - if (count > 200) { - pr_err("[LNK/E]<%s:%d>\n", __func__, __LINE__); - in_interrupt = dpctl->recv_msg(); - if (in_interrupt == 0x1234) { - pr_info("[LNK] [in_interrupt]: 0x%04x\n", - in_interrupt); - break; - } - return -1; - } - } - out_interrupt = 0xDEAD; - dpctl->send_msg(out_interrupt); - - return retval; -} - -static int msm_uload_step2(void *arg, struct modemlink_dpram_control *dpctl) -{ - int retval = 0; - struct _param_nv param; - - retval = copy_from_user((void *)¶m, (void *)arg, sizeof(param)); - if (retval < 0) { - pr_err("[LNK/E]<%s:%d>\n", __func__, __LINE__); - return -1; - } - - retval = msm_data_upload(¶m, dpctl); - if (retval < 0) { - pr_err("[LNK/E]<%s:%d>\n", __func__, __LINE__); - return -1; - } - - if (!(param.count % 500)) - pr_info("[LNK] [param->count]:%d\n", param.count); - - if (param.tag == 4) { - dpctl->clear_intr(); - enable_irq(msm_edpram_ctrl.dpram_irq); - pr_info("[LNK] [param->tag]:%d\n", param.tag); - } - - retval = copy_to_user((unsigned long *)arg, ¶m, sizeof(param)); - if (retval < 0) { - pr_err("[LNK/E]<%s:%d>\n", __func__, __LINE__); - return -1; - } - - return retval; -} - -static int msm_dload_prep(struct modemlink_dpram_control *dpctl) -{ - int retval = 0; - int count = 0; - - while (1) { - if (check_param.copy_start) { - check_param.copy_start = 0; - break; - } - msleep_interruptible(10); - count++; - if (count > 200) { - pr_err("[LNK/E]<%s:%d>\n", __func__, __LINE__); - return -1; - } - } - - return retval; -} - -static int msm_dload(void *arg, struct modemlink_dpram_control *dpctl) -{ - int retval = 0; - int count = 0; - struct _param_nv param; - - retval = copy_from_user((void *)¶m, (void *)arg, sizeof(param)); - if (retval < 0) { - pr_err("[LNK/E]<%s:%d>\n", __func__, __LINE__); - return -1; - } - - img = vmalloc(param.size); - if (img == NULL) { - pr_err("[LNK/E]<%s:%d>\n", __func__, __LINE__); - return -1; - } - memset(img, 0, param.size); - memcpy(img, param.addr, param.size); - - data_param = kzalloc(sizeof(struct _param_nv), GFP_KERNEL); - if (data_param == NULL) { - pr_err("[LNK/E]<%s:%d>\n", __func__, __LINE__); - vfree(img); - img = NULL; - return -1; - } - - check_param.total_size = param.size; - check_param.rest_size = param.size; - check_param.send_size = 0; - check_param.copy_complete = 0; - - data_param->addr = img; - data_param->size = DP_BOOT_FRAME_SIZE_LIMIT; - data_param->count = param.count; - - data_param->tag = 0x0001; - - if (check_param.rest_size < DP_BOOT_FRAME_SIZE_LIMIT) - data_param->size = check_param.rest_size; - - retval = msm_data_load(data_param, dpctl); - - while (1) { - if (check_param.copy_complete) { - check_param.copy_complete = 0; - - vfree(img); - img = NULL; - kfree(data_param); - data_param = NULL; - - break; - } - msleep_interruptible(10); - count++; - if (count > 1000) { - pr_err("[LNK/E]<%s:%d>\n", __func__, __LINE__); - vfree(img); - img = NULL; - kfree(data_param); - data_param = NULL; - return -1; - } - } - - return retval; - -} - -static int msm_nv_load(void *arg, struct modemlink_dpram_control *dpctl) -{ - int retval = 0; - int count = 0; - struct _param_nv param; - - retval = copy_from_user((void *)¶m, (void *)arg, sizeof(param)); - if (retval < 0) { - pr_err("[LNK/E]<%s:%d>\n", __func__, __LINE__); - return -1; - } - - nv_img = vmalloc(param.size); - if (nv_img == NULL) { - pr_err("[LNK/E]<%s:%d>\n", __func__, __LINE__); - return -1; - } - memset(nv_img, 0, param.size); - memcpy(nv_img, param.addr, param.size); - - data_param = kzalloc(sizeof(struct _param_nv), GFP_KERNEL); - if (data_param == NULL) { - pr_err("[LNK/E]<%s:%d>\n", __func__, __LINE__); - vfree(nv_img); - nv_img = NULL; - return -1; - } - - check_param.total_size = param.size; - check_param.rest_size = param.size; - check_param.send_size = 0; - check_param.copy_complete = 0; - - data_param->addr = nv_img; - data_param->size = DP_BOOT_FRAME_SIZE_LIMIT; - data_param->count = 1; - data_param->tag = 0x0002; - - if (check_param.rest_size < DP_BOOT_FRAME_SIZE_LIMIT) - data_param->size = check_param.rest_size; - - retval = msm_data_load(data_param, dpctl); - - while (1) { - if (check_param.copy_complete) { - check_param.copy_complete = 0; - - vfree(nv_img); - nv_img = NULL; - kfree(data_param); - data_param = NULL; - break; - } - msleep_interruptible(10); - count++; - if (count > 200) { - pr_err("[LNK/E]<%s:%d>\n", __func__, __LINE__); - vfree(nv_img); - nv_img = NULL; - kfree(data_param); - data_param = NULL; - return -1; - } - } - - return retval; - -} - -static int msm_boot_start(struct modemlink_dpram_control *dpctl) -{ - - u16 out_interrupt = 0; - int count = 0; - - /* Send interrupt -> '0x4567' */ - out_interrupt = 0x4567; - dpctl->send_msg(out_interrupt); - - while (1) { - if (check_param.boot_complete) { - check_param.boot_complete = 0; - break; - } - msleep_interruptible(10); - count++; - if (count > 200) { - pr_err("[LNK/E]<%s:%d>\n", __func__, __LINE__); - return -1; - } - } - - return 0; -} - - -static void msm_terminate_link(struct modemlink_dpram_control *dpctl) -{ - pr_info("[LNK] +--------------msm_terminate_link------------+\n"); - if (img != NULL) { - pr_info("[LNK] +--------------img free----------------+\n"); - vfree(img); - img = NULL; - } - if (nv_img != NULL) { - pr_info("[LNK] +--------------nv_img free----------------+\n"); - vfree(nv_img); - nv_img = NULL; - } - if (data_param != NULL) { - pr_info("[LNK] +--------------data_param free----------------+\n"); - kfree(data_param); - data_param = NULL; - } - -} - -static struct modemlink_dpram_control *tasklet_dpctl; - -static void interruptable_load_tasklet_handler(unsigned long data); - -static DECLARE_TASKLET(interruptable_load_tasklet, - interruptable_load_tasklet_handler, - (unsigned long)&tasklet_dpctl); - -static void interruptable_load_tasklet_handler(unsigned long data) -{ - struct modemlink_dpram_control *dpctl = - (struct modemlink_dpram_control *) - (*((struct modemlink_dpram_control **)data)); - - if (data_param == NULL) { - pr_err("[LNK/E]<%s:%d>\n", __func__, __LINE__); - return; - } - - check_param.send_size += data_param->size; - check_param.rest_size -= data_param->size; - data_param->addr += data_param->size; - - if (check_param.send_size < check_param.total_size) { - - if (check_param.rest_size < DP_BOOT_FRAME_SIZE_LIMIT) - data_param->size = check_param.rest_size; - - data_param->count += 1; - - msm_data_load(data_param, dpctl); - } else { - data_param->tag = 0; - check_param.copy_complete = 1; - } - -} - -static int msm_boot_start_post_proc(void) -{ - int count = 0; - - while (1) { - if (boot_start_complete) { - boot_start_complete = 0; - break; - } - msleep_interruptible(10); - count++; - if (count > 200) { - pr_err("[LNK/E]<%s:%d>\n", __func__, __LINE__); - return -1; - } - } - - return 0; -} - -static void msm_boot_start_handler(struct modemlink_dpram_control *dpctl) -{ - boot_start_complete = 1; - - /* Send INIT_END code to CP */ - pr_info("[LNK] <%s> Send 0x11C2 (INIT_END)\n", __func__); - - /* - * INT_MASK_VALID|INT_MASK_CMD|INT_MASK_CP_AIRPLANE_BOOT| - * INT_MASK_CP_AP_ANDROID|INT_MASK_CMD_INIT_END - */ - dpctl->send_intr((0x0080 | 0x0040 | 0x1000 | 0x0100 | 0x0002)); -} - -static void msm_dload_handler(struct modemlink_dpram_control *dpctl, u16 cmd) -{ - switch (cmd) { - case 0x1234: - check_param.copy_start = 1; - break; - - case 0xDBAB: - tasklet_schedule(&interruptable_load_tasklet); - break; - - case 0xABCD: - check_param.boot_complete = 1; - break; - - default: - pr_err("[LNK/Err] <%s> Unknown command.. %x\n", __func__, cmd); - } -} - -static void msm_bt_map_init(struct modemlink_dpram_control *dpctl) -{ - msm_edpram_bt_map.buff = (u8 *) (dpctl->dp_base); - msm_edpram_bt_map.frame_size = - (u16 *) (dpctl->dp_base + DP_BOOT_SIZE_OFFSET); - msm_edpram_bt_map.tag = (u16 *) (dpctl->dp_base + DP_BOOT_TAG_OFFSET); - msm_edpram_bt_map.count = - (u16 *) (dpctl->dp_base + DP_BOOT_COUNT_OFFSET); -} - -static void msm_load_init(struct modemlink_dpram_control *dpctl) -{ - tasklet_dpctl = dpctl; - if (tasklet_dpctl == NULL) - pr_err("[LNK/Err] failed tasklet_dpctl remap\n"); - - check_param.total_size = 0; - check_param.rest_size = 0; - check_param.send_size = 0; - check_param.copy_start = 0; - check_param.copy_complete = 0; - check_param.boot_complete = 0; - - dpctl->clear_intr(); -} - -static irqreturn_t host_wakeup_isr(int irq, void *dev) -{ - pr_err("[MODEMS] <%s>\n", __func__); - - return IRQ_HANDLED; -} - static void config_cdma_modem_gpio(void) { int err; @@ -1197,13 +769,21 @@ static void config_cdma_modem_gpio(void) unsigned gpio_pda_active = cdma_modem_data.gpio_pda_active; unsigned gpio_phone_active = cdma_modem_data.gpio_phone_active; unsigned gpio_flm_uart_sel = cdma_modem_data.gpio_flm_uart_sel; -#if 1 +#if defined(CONFIG_MACH_M0_CTC) unsigned gpio_flm_uart_sel_rev06 = - cdma_modem_data.gpio_flm_uart_sel_rev06; + cdma_modem_data.gpio_flm_uart_sel_rev06; + unsigned gpio_host_wakeup = cdma_modem_data.gpio_host_wakeup; #endif unsigned gpio_dpram_int = cdma_modem_data.gpio_dpram_int; - unsigned gpio_host_wakeup = cdma_modem_data.gpio_host_wakeup; - + unsigned gpio_cp_dump_int = cdma_modem_data.gpio_cp_dump_int; + unsigned gpio_sim_detect = cdma_modem_data.gpio_sim_detect; + +#if defined(CONFIG_LINK_DEVICE_PLD) + unsigned gpio_fpga2_creset = cdma_modem_data.gpio_fpga2_creset; + unsigned gpio_fpga2_cdone = cdma_modem_data.gpio_fpga2_cdone; + unsigned gpio_fpga2_rst_n = cdma_modem_data.gpio_fpga2_rst_n; + unsigned gpio_fpga2_cs_n = cdma_modem_data.gpio_fpga2_cs_n; +#endif pr_info("[MODEMS] <%s>\n", __func__); if (gpio_pda_active) { @@ -1211,7 +791,7 @@ static void config_cdma_modem_gpio(void) if (err) { pr_err("fail to request gpio %s\n", "PDA_ACTIVE"); } else { - gpio_direction_output(gpio_pda_active, 1); + gpio_direction_output(gpio_pda_active, 0); s3c_gpio_setpull(gpio_pda_active, S3C_GPIO_PULL_NONE); gpio_set_value(gpio_pda_active, 0); } @@ -1234,10 +814,10 @@ static void config_cdma_modem_gpio(void) if (err) { pr_err("fail request gpio %s\n", "BOOT_SW_SEL"); } else { - gpio_direction_output(gpio_flm_uart_sel, 1); + gpio_direction_output(gpio_flm_uart_sel, 0); s3c_gpio_setpull(gpio_flm_uart_sel, S3C_GPIO_PULL_NONE); - gpio_set_value(gpio_flm_uart_sel, 1); + gpio_set_value(gpio_flm_uart_sel, 0); } } } else if (system_rev == 11) { @@ -1246,12 +826,13 @@ static void config_cdma_modem_gpio(void) if (err) { pr_err("fail request gpio %s\n", "BOOT_SW_SEL"); } else { - gpio_direction_output(gpio_flm_uart_sel, 1); + gpio_direction_output(gpio_flm_uart_sel, 0); s3c_gpio_setpull(gpio_flm_uart_sel, S3C_GPIO_PULL_NONE); - gpio_set_value(gpio_flm_uart_sel, 1); + gpio_set_value(gpio_flm_uart_sel, 0); } } +#if defined(CONFIG_MACH_M0_CTC) if (gpio_flm_uart_sel_rev06) { err = gpio_request(gpio_flm_uart_sel_rev06, "BOOT_SW_SEL_REV06"); @@ -1260,23 +841,26 @@ static void config_cdma_modem_gpio(void) "BOOT_SW_SEL_REV06"); } else { gpio_direction_output(gpio_flm_uart_sel_rev06, - 1); + 0); s3c_gpio_setpull(gpio_flm_uart_sel_rev06, S3C_GPIO_PULL_NONE); - gpio_set_value(gpio_flm_uart_sel_rev06, 1); + gpio_set_value(gpio_flm_uart_sel_rev06, 0); } } +#endif } else { +#if defined(CONFIG_MACH_M0_CTC) err = gpio_request(gpio_flm_uart_sel_rev06, "BOOT_SW_SEL_REV06"); if (err) { pr_err("fail request gpio %s\n", "BOOT_SW_SEL_REV06"); } else { - gpio_direction_output(gpio_flm_uart_sel_rev06, 1); + gpio_direction_output(gpio_flm_uart_sel_rev06, 0); s3c_gpio_setpull(gpio_flm_uart_sel_rev06, S3C_GPIO_PULL_NONE); - gpio_set_value(gpio_flm_uart_sel_rev06, 1); + gpio_set_value(gpio_flm_uart_sel_rev06, 0); } +#endif } if (gpio_cp_on) { @@ -1284,7 +868,7 @@ static void config_cdma_modem_gpio(void) if (err) { pr_err("fail to request gpio %s\n", "MSM_ON"); } else { - gpio_direction_output(gpio_cp_on, 1); + gpio_direction_output(gpio_cp_on, 0); s3c_gpio_setpull(gpio_cp_on, S3C_GPIO_PULL_NONE); gpio_set_value(gpio_cp_on, 0); } @@ -1306,7 +890,7 @@ static void config_cdma_modem_gpio(void) if (err) { pr_err("fail to request gpio %s\n", "MSM_RST_REQ"); } else { - gpio_direction_output(gpio_rst_req_n, 1); + gpio_direction_output(gpio_rst_req_n, 0); s3c_gpio_setpull(gpio_rst_req_n, S3C_GPIO_PULL_NONE); } gpio_set_value(gpio_rst_req_n, 0); @@ -1317,7 +901,7 @@ static void config_cdma_modem_gpio(void) if (err) { pr_err("fail to request gpio %s\n", "MSM_RST"); } else { - gpio_direction_output(gpio_cp_rst, 1); + gpio_direction_output(gpio_cp_rst, 0); s3c_gpio_setpull(gpio_cp_rst, S3C_GPIO_PULL_NONE); } gpio_set_value(gpio_cp_rst, 0); @@ -1334,6 +918,7 @@ static void config_cdma_modem_gpio(void) } } +#if defined(CONFIG_MACH_M0_CTC) if (gpio_host_wakeup) { err = gpio_request(gpio_host_wakeup, "MSM_HOST_WAKEUP"); if (err) { @@ -1346,6 +931,76 @@ static void config_cdma_modem_gpio(void) IRQ_TYPE_LEVEL_HIGH); } } +#endif + + if (gpio_cp_dump_int) { + err = gpio_request(gpio_cp_dump_int, "MSM_CP_DUMP_INT"); + if (err) { + pr_err("fail to request gpio %s\n", "MSM_CP_DUMP_INT"); + } else { + s3c_gpio_cfgpin(gpio_cp_dump_int, S3C_GPIO_INPUT); + s3c_gpio_setpull(gpio_cp_dump_int, S3C_GPIO_PULL_DOWN); + } + } + +#if defined(CONFIG_LINK_DEVICE_PLD) + if (gpio_fpga2_creset) { + err = gpio_request(gpio_fpga2_creset, "FPGA2_CRESET"); + if (err) { + pr_err("fail to request gpio %s, gpio %d, errno %d\n", + "FPGA2_CRESET", gpio_fpga2_creset, err); + } else { + gpio_direction_output(gpio_fpga2_creset, 0); + s3c_gpio_setpull(gpio_fpga2_creset, S3C_GPIO_PULL_NONE); + } + } + + if (gpio_fpga2_cdone) { + err = gpio_request(gpio_fpga2_cdone, "FPGA2_CDONE"); + if (err) { + pr_err("fail to request gpio %s, gpio %d, errno %d\n", + "FPGA2_CDONE", gpio_fpga2_cdone, err); + } else { + s3c_gpio_cfgpin(gpio_fpga2_cdone, S3C_GPIO_INPUT); + s3c_gpio_setpull(gpio_fpga2_cdone, S3C_GPIO_PULL_NONE); + } + } + + if (gpio_fpga2_rst_n) { + err = gpio_request(gpio_fpga2_rst_n, "FPGA2_RESET"); + if (err) { + pr_err("fail to request gpio %s, gpio %d, errno %d\n", + "FPGA2_RESET", gpio_fpga2_rst_n, err); + } else { + gpio_direction_output(gpio_fpga2_rst_n, 0); + s3c_gpio_setpull(gpio_fpga2_rst_n, S3C_GPIO_PULL_NONE); + } + } + + if (gpio_fpga2_cs_n) { + err = gpio_request(gpio_fpga2_cs_n, "SPI_CS2_1"); + if (err) { + pr_err("fail to request gpio %s, gpio %d, errno %d\n", + "SPI_CS2_1", gpio_fpga2_cs_n, err); + } else { + gpio_direction_output(gpio_fpga2_cs_n, 0); + s3c_gpio_setpull(gpio_fpga2_cs_n, S3C_GPIO_PULL_NONE); + } + } +#endif + + if (gpio_sim_detect) { + err = gpio_request(gpio_sim_detect, "MSM_SIM_DETECT"); + if (err) { + pr_err("fail to request gpio %s: %d\n", + "MSM_SIM_DETECT", err); + } else { + /* gpio_direction_input(gpio_sim_detect); */ + s3c_gpio_cfgpin(gpio_sim_detect, S3C_GPIO_SFN(0xF)); + s3c_gpio_setpull(gpio_sim_detect, S3C_GPIO_PULL_NONE); + irq_set_irq_type(gpio_sim_detect, IRQ_TYPE_EDGE_BOTH); + } + } } static u8 *msm_edpram_remap_mem_region(struct sromc_cfg *cfg) @@ -1371,9 +1026,20 @@ static u8 *msm_edpram_remap_mem_region(struct sromc_cfg *cfg) /* Map for IPC */ ipc_map = (struct msm_edpram_ipc_cfg *)dp_base; +#if defined(CONFIG_LINK_DEVICE_PLD) + /* Magic code and access enable fields */ + msm_ipc_map.magic_ap2cp = (u16 __iomem *) &ipc_map->magic_ap2cp; + msm_ipc_map.access_ap2cp = (u16 __iomem *) &ipc_map->access_ap2cp; + + msm_ipc_map.magic_cp2ap = (u16 __iomem *) &ipc_map->magic_cp2ap; + msm_ipc_map.access_cp2ap = (u16 __iomem *) &ipc_map->access_cp2ap; + + msm_ipc_map.address_buffer = (u16 __iomem *) &ipc_map->address_buffer; +#else /* Magic code and access enable fields */ msm_ipc_map.magic = (u16 __iomem *) &ipc_map->magic; msm_ipc_map.access = (u16 __iomem *) &ipc_map->access; +#endif /* FMT */ dev = &msm_ipc_map.dev[IPC_FMT]; @@ -1415,28 +1081,6 @@ static u8 *msm_edpram_remap_mem_region(struct sromc_cfg *cfg) dev->mask_res_ack = INT_MASK_RES_ACK_R; dev->mask_send = INT_MASK_SEND_R; -#if 0 - /* RFS */ - dev = &msm_ipc_map.dev[IPC_RFS]; - - strcpy(dev->name, "RFS"); - dev->id = IPC_RFS; - - dev->txq.head = (u16 __iomem *) &ipc_map->rfs_tx_head; - dev->txq.tail = (u16 __iomem *) &ipc_map->rfs_tx_tail; - dev->txq.buff = (u8 __iomem *) &ipc_map->rfs_tx_buff[0]; - dev->txq.size = MSM_DP_RFS_TX_BUFF_SZ; - - dev->rxq.head = (u16 __iomem *) &ipc_map->rfs_rx_head; - dev->rxq.tail = (u16 __iomem *) &ipc_map->rfs_rx_tail; - dev->rxq.buff = (u8 __iomem *) &ipc_map->rfs_rx_buff[0]; - dev->rxq.size = MSM_DP_RFS_RX_BUFF_SZ; - - dev->mask_req_ack = INT_MASK_REQ_ACK_RFS; - dev->mask_res_ack = INT_MASK_RES_ACK_RFS; - dev->mask_send = INT_MASK_SEND_RFS; -#endif - /* Mailboxes */ msm_ipc_map.mbx_ap2cp = (u16 __iomem *) &ipc_map->mbx_ap2cp; msm_ipc_map.mbx_cp2ap = (u16 __iomem *) &ipc_map->mbx_cp2ap; @@ -1481,18 +1125,36 @@ static void config_dpram_port_gpio(void) __func__, addr_bits - EXYNOS4_GPIO_Y3_NR); break; + case 15: + s3c_gpio_cfgrange_nopull(EXYNOS4_GPY3(0), EXYNOS4_GPIO_Y3_NR, + S3C_GPIO_SFN(2)); + s3c_gpio_cfgrange_nopull(EXYNOS4_GPY4(0), EXYNOS4_GPIO_Y4_NR, + S3C_GPIO_SFN(2)); + pr_info("[MDM] <%s> last data gpio EXYNOS4_GPY4(0) ~ %d\n", + __func__, EXYNOS4_GPIO_Y4_NR); + break; + + default: pr_err("[MDM/E] <%s> Invalid addr_bits!!!\n", __func__); return; } /* Set GPIO for dpram data - 16bit */ +#if defined(CONFIG_LINK_DEVICE_PLD) + s3c_gpio_cfgrange_nopull(EXYNOS4_GPY5(0), 8, S3C_GPIO_SFN(2)); +#elif defined(CONFIG_LINK_DEVICE_DPRAM) s3c_gpio_cfgrange_nopull(EXYNOS4_GPY5(0), 8, S3C_GPIO_SFN(2)); s3c_gpio_cfgrange_nopull(EXYNOS4_GPY6(0), 8, S3C_GPIO_SFN(2)); +#endif /* Setup SROMC CSn pins */ s3c_gpio_cfgpin(GPIO_DPRAM_CSN0, S3C_GPIO_SFN(2)); +#if defined(CONFIG_GSM_MODEM_ESC6270) + s3c_gpio_cfgpin(GPIO_DPRAM_CSN1, S3C_GPIO_SFN(2)); +#endif + /* Config OEn, WEn */ s3c_gpio_cfgrange_nopull(GPIO_DPRAM_REN, 2, S3C_GPIO_SFN(2)); @@ -1500,7 +1162,9 @@ static void config_dpram_port_gpio(void) s3c_gpio_cfgrange_nopull(GPIO_DPRAM_LBN, 2, S3C_GPIO_SFN(2)); /* Config BUSY */ +#if !defined(CONFIG_LINK_DEVICE_PLD) s3c_gpio_cfgpin(GPIO_DPRAM_BUSY, S3C_GPIO_SFN(2)); +#endif } static void init_sromc(void) @@ -1516,8 +1180,9 @@ static void init_sromc(void) clk_enable(clk); } -static void setup_sromc -(unsigned csn, struct sromc_cfg *cfg, struct sromc_access_cfg *acc_cfg) { +static void setup_sromc(unsigned csn, struct sromc_cfg *cfg, + struct sromc_access_cfg *acc_cfg) +{ unsigned bw = 0; unsigned bc = 0; void __iomem *bank_sfr = S5P_SROM_BC0 + (4 * csn); @@ -1532,13 +1197,13 @@ static void setup_sromc /* Set the BW control field for the CSn */ bw &= ~(SROMC_MASK << (csn * 4)); - if (cfg->attr | MEM_DATA_BUS_16BIT) + if (cfg->attr & MEM_DATA_BUS_16BIT) bw |= (SROMC_DATA_16 << (csn * 4)); - if (cfg->attr | MEM_WAIT_EN) + if (cfg->attr & MEM_WAIT_EN) bw |= (SROMC_WAIT_EN << (csn * 4)); - if (cfg->attr | MEM_BYTE_EN) + if (cfg->attr & MEM_BYTE_EN) bw |= (SROMC_BYTE_EN << (csn * 4)); writel(bw, S5P_SROM_BW); @@ -1556,34 +1221,803 @@ static void setup_sromc __func__, bw, csn, bc); } -static void setup_dpram_speed(unsigned csn, struct sromc_access_cfg *acc_cfg) +/* For ESC6270 modem */ +#if defined(CONFIG_GSM_MODEM_ESC6270) +static struct dpram_ipc_map gsm_ipc_map; + +#if defined(CONFIG_LINK_DEVICE_PLD) +static struct sromc_cfg gsm_edpram_cfg = { + .attr = (MEM_DATA_BUS_8BIT), + .size = 0x10000, +}; +#else +static struct sromc_cfg gsm_edpram_cfg = { + .attr = (MEM_DATA_BUS_16BIT | MEM_WAIT_EN | MEM_BYTE_EN), + .size = MSM_EDPRAM_SIZE, +}; +#endif + +#if defined(CONFIG_LINK_DEVICE_PLD) +static struct sromc_access_cfg gsm_edpram_access_cfg[] = { + [DPRAM_SPEED_LOW] = { + .tacs = 0x2 << 28, + .tcos = 0x2 << 24, + .tacc = 0x3 << 16, + .tcoh = 0x2 << 12, + .tcah = 0x2 << 8, + .tacp = 0x2 << 4, + .pmc = 0x0 << 0, + }, +}; +#else +static struct sromc_access_cfg gsm_edpram_access_cfg[] = { + [DPRAM_SPEED_LOW] = { + .tacs = 0x2 << 28, + .tcos = 0x2 << 24, + .tacc = 0x3 << 16, + .tcoh = 0x2 << 12, + .tcah = 0x2 << 8, + .tacp = 0x2 << 4, + .pmc = 0x0 << 0, + }, +}; +#endif + +static struct modemlink_dpram_control gsm_edpram_ctrl = { + .dp_type = EXT_DPRAM, + + .dpram_irq = ESC_DPRAM_INT_IRQ, + .dpram_irq_flags = IRQF_TRIGGER_FALLING, + + .max_ipc_dev = IPC_RFS, + .ipc_map = &gsm_ipc_map, + + .boot_size_offset = DP_BOOT_SIZE_OFFSET, + .boot_tag_offset = DP_BOOT_TAG_OFFSET, + .boot_count_offset = DP_BOOT_COUNT_OFFSET, + .max_boot_frame_size = DP_BOOT_FRAME_SIZE_LIMIT, + +#if defined(CONFIG_LINK_DEVICE_PLD) + .aligned = 1, +#endif +}; + +/* +** GSM target platform data +*/ +#if defined(CONFIG_LINK_DEVICE_PLD) +static struct modem_io_t gsm_io_devices[] = { + [0] = { + .name = "gsm_boot0", + .id = 0x1, + .format = IPC_BOOT, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_PLD), + }, + [1] = { + .name = "gsm_ipc0", + .id = 0x01, + .format = IPC_FMT, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_PLD), + }, + [2] = { + .name = "gsm_rfs0", + .id = 0x28, + .format = IPC_RAW, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_PLD), + }, + [3] = { + .name = "gsm_multi_pdp", + .id = 0x1, + .format = IPC_MULTI_RAW, + .io_type = IODEV_DUMMY, + .links = LINKTYPE(LINKDEV_PLD), + }, + [4] = { + .name = "gsm_rmnet0", + .id = 0x2A, + .format = IPC_RAW, + .io_type = IODEV_NET, + .links = LINKTYPE(LINKDEV_PLD), + }, + [5] = { + .name = "gsm_rmnet1", + .id = 0x2B, + .format = IPC_RAW, + .io_type = IODEV_NET, + .links = LINKTYPE(LINKDEV_PLD), + }, + [6] = { + .name = "gsm_rmnet2", + .id = 0x2C, + .format = IPC_RAW, + .io_type = IODEV_NET, + .links = LINKTYPE(LINKDEV_PLD), + }, + [7] = { + .name = "gsm_router", + .id = 0x39, + .format = IPC_RAW, + .io_type = IODEV_NET, + .links = LINKTYPE(LINKDEV_PLD), + }, + [8] = { + .name = "gsm_csd", + .id = 0x21, + .format = IPC_RAW, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_PLD), + }, + [9] = { + .name = "gsm_ramdump0", + .id = 0x1, + .format = IPC_RAMDUMP, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_PLD), + }, + [10] = { + .name = "gsm_loopback0", + .id = 0x3F, + .format = IPC_RAW, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_PLD), + }, +}; +#else +static struct modem_io_t gsm_io_devices[] = { + [0] = { + .name = "gsm_boot0", + .id = 0x1, + .format = IPC_BOOT, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_DPRAM), + }, + [1] = { + .name = "gsm_ipc0", + .id = 0x01, + .format = IPC_FMT, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_DPRAM), + }, + [2] = { + .name = "gsm_rfs0", + .id = 0x28, + .format = IPC_RAW, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_DPRAM), + }, + [3] = { + .name = "gsm_multi_pdp", + .id = 0x1, + .format = IPC_MULTI_RAW, + .io_type = IODEV_DUMMY, + .links = LINKTYPE(LINKDEV_DPRAM), + }, + [4] = { + .name = "gsm_rmnet0", + .id = 0x2A, + .format = IPC_RAW, + .io_type = IODEV_NET, + .links = LINKTYPE(LINKDEV_DPRAM), + }, + [5] = { + .name = "gsm_rmnet1", + .id = 0x2B, + .format = IPC_RAW, + .io_type = IODEV_NET, + .links = LINKTYPE(LINKDEV_DPRAM), + }, + [6] = { + .name = "gsm_rmnet2", + .id = 0x2C, + .format = IPC_RAW, + .io_type = IODEV_NET, + .links = LINKTYPE(LINKDEV_DPRAM), + }, + [7] = { + .name = "gsm_router", + .id = 0x39, + .format = IPC_RAW, + .io_type = IODEV_NET, + .links = LINKTYPE(LINKDEV_DPRAM), + }, + [8] = { + .name = "gsm_csd", + .id = 0x21, + .format = IPC_RAW, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_DPRAM), + }, + [9] = { + .name = "gsm_ramdump0", + .id = 0x1, + .format = IPC_RAMDUMP, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_DPRAM), + }, + [10] = { + .name = "gsm_loopback0", + .id = 0x3F, + .format = IPC_RAW, + .io_type = IODEV_MISC, + .links = LINKTYPE(LINKDEV_DPRAM), + }, +}; +#endif + +static struct modem_data gsm_modem_data = { + .name = "esc6270", + + .gpio_cp_on = GPIO_CP2_MSM_PWRON, + .gpio_cp_off = 0, + .gpio_reset_req_n = 0, /* GPIO_CP_MSM_PMU_RST, */ + .gpio_cp_reset = GPIO_CP2_MSM_RST, + .gpio_pda_active = 0, + .gpio_phone_active = GPIO_ESC_PHONE_ACTIVE, + .gpio_flm_uart_sel = GPIO_BOOT_SW_SEL_CP2, + + .gpio_dpram_int = GPIO_ESC_DPRAM_INT, + + .gpio_cp_dump_int = 0, + .gpio_cp_warm_reset = 0, + +#if defined(CONFIG_SIM_DETECT) + .gpio_sim_detect = GPIO_ESC_SIM_DETECT, +#else + .gpio_sim_detect = 0, +#endif + +#if defined(CONFIG_LINK_DEVICE_PLD) + .gpio_fpga1_creset = GPIO_FPGA1_CRESET, + .gpio_fpga1_cdone = GPIO_FPGA1_CDONE, + .gpio_fpga1_rst_n = GPIO_FPGA1_RST_N, + .gpio_fpga1_cs_n = GPIO_FPGA1_CS_N, +#endif + + .use_handover = false, + + .modem_net = CDMA_NETWORK, + .modem_type = QC_ESC6270, +#if defined(CONFIG_LINK_DEVICE_PLD) + .link_types = LINKTYPE(LINKDEV_PLD), +#else + .link_types = LINKTYPE(LINKDEV_DPRAM), +#endif + .link_name = "esc6270_edpram", + .dpram_ctl = &gsm_edpram_ctrl, + + .ipc_version = SIPC_VER_41, + + .num_iodevs = ARRAY_SIZE(gsm_io_devices), + .iodevs = gsm_io_devices, +}; + +static struct resource gsm_modem_res[] = { + [0] = { + .name = "cp_active_irq", + .start = ESC_PHONE_ACTIVE_IRQ, + .end = ESC_PHONE_ACTIVE_IRQ, + .flags = IORESOURCE_IRQ, + }, + [1] = { + .name = "dpram_irq", + .start = ESC_DPRAM_INT_IRQ, + .end = ESC_DPRAM_INT_IRQ, + .flags = IORESOURCE_IRQ, + }, +#if defined(CONFIG_SIM_DETECT) + [2] = { + .name = "sim_irq", + .start = ESC_SIM_DETECT_IRQ, + .end = ESC_SIM_DETECT_IRQ, + .flags = IORESOURCE_IRQ, + }, +#endif +}; + +static struct platform_device gsm_modem = { + .name = "modem_if", + .id = 1, + .num_resources = ARRAY_SIZE(gsm_modem_res), + .resource = gsm_modem_res, + .dev = { + .platform_data = &gsm_modem_data, + }, +}; + +void config_gsm_modem_gpio(void) { - void __iomem *bank_sfr = S5P_SROM_BC0 + (4 * csn); - unsigned bc = 0; + int err = 0; + unsigned gpio_cp_on = gsm_modem_data.gpio_cp_on; + unsigned gpio_cp_off = gsm_modem_data.gpio_cp_off; + unsigned gpio_rst_req_n = gsm_modem_data.gpio_reset_req_n; + unsigned gpio_cp_rst = gsm_modem_data.gpio_cp_reset; + unsigned gpio_pda_active = gsm_modem_data.gpio_pda_active; + unsigned gpio_phone_active = gsm_modem_data.gpio_phone_active; + unsigned gpio_flm_uart_sel = gsm_modem_data.gpio_flm_uart_sel; + unsigned gpio_dpram_int = gsm_modem_data.gpio_dpram_int; + unsigned gpio_sim_detect = gsm_modem_data.gpio_sim_detect; + +#if defined(CONFIG_LINK_DEVICE_PLD) + unsigned gpio_fpga1_creset = gsm_modem_data.gpio_fpga1_creset; + unsigned gpio_fpga1_cdone = gsm_modem_data.gpio_fpga1_cdone; + unsigned gpio_fpga1_rst_n = gsm_modem_data.gpio_fpga1_rst_n; + unsigned gpio_fpga1_cs_n = gsm_modem_data.gpio_fpga1_cs_n; +#endif - bc = __raw_readl(bank_sfr); - pr_info("[MDM] <%s> Old CS%d setting = 0x%08X\n", __func__, csn, bc); + pr_err("[MODEMS] <%s>\n", __func__); - /* SROMC memory access timing setting */ - bc = acc_cfg->tacs | acc_cfg->tcos | acc_cfg->tacc | - acc_cfg->tcoh | acc_cfg->tcah | acc_cfg->tacp | acc_cfg->pmc; - writel(bc, bank_sfr); + if (gpio_pda_active) { + err = gpio_request(gpio_pda_active, "PDA_ACTIVE"); + if (err) { + pr_err("fail to request gpio %s, gpio %d, errno %d\n", + "PDA_ACTIVE", gpio_pda_active, err); + } else { + gpio_direction_output(gpio_pda_active, 1); + s3c_gpio_setpull(gpio_pda_active, S3C_GPIO_PULL_NONE); + gpio_set_value(gpio_pda_active, 0); + } + } - bc = __raw_readl(bank_sfr); - pr_err("[MDM] <%s> New CS%d setting = 0x%08X\n", __func__, csn, bc); + if (gpio_phone_active) { + err = gpio_request(gpio_phone_active, "ESC_ACTIVE"); + if (err) { + pr_err("fail to request gpio %s, gpio %d, errno %d\n", + "ESC_ACTIVE", gpio_phone_active, err); + } else { + s3c_gpio_cfgpin(gpio_phone_active, S3C_GPIO_SFN(0xF)); + s3c_gpio_setpull(gpio_phone_active, S3C_GPIO_PULL_NONE); + irq_set_irq_type(gpio_phone_active, IRQ_TYPE_EDGE_BOTH); + } + } + + if (gpio_flm_uart_sel) { + err = gpio_request(gpio_flm_uart_sel, "BOOT_SW_SEL2"); + if (err) { + pr_err("fail to request gpio %s, gpio %d, errno %d\n", + "BOOT_SW_SEL2", gpio_flm_uart_sel, err); + } else { + gpio_direction_output(gpio_flm_uart_sel, 1); + s3c_gpio_setpull(gpio_flm_uart_sel, S3C_GPIO_PULL_NONE); + gpio_set_value(gpio_flm_uart_sel, 1); + } + } + + if (gpio_cp_on) { + err = gpio_request(gpio_cp_on, "ESC_ON"); + if (err) { + pr_err("fail to request gpio %s, gpio %d, errno %d\n", + "ESC_ON", gpio_cp_on, err); + } else { + gpio_direction_output(gpio_cp_on, 0); + s3c_gpio_setpull(gpio_cp_on, S3C_GPIO_PULL_NONE); + s5p_gpio_set_drvstr(gpio_cp_on, S5P_GPIO_DRVSTR_LV1); + gpio_set_value(gpio_cp_on, 0); + } + } + + if (gpio_cp_off) { + err = gpio_request(gpio_cp_off, "ESC_OFF"); + if (err) { + pr_err("fail to request gpio %s, gpio %d, errno %d\n", + "ESC_OFF", (gpio_cp_off), err); + } else { + gpio_direction_output(gpio_cp_off, 1); + s3c_gpio_setpull(gpio_cp_off, S3C_GPIO_PULL_NONE); + gpio_set_value(gpio_cp_off, 1); + } + } + + if (gpio_rst_req_n) { + err = gpio_request(gpio_rst_req_n, "ESC_RST_REQ"); + if (err) { + pr_err("fail to request gpio %s, gpio %d, errno %d\n", + "ESC_RST_REQ", gpio_rst_req_n, err); + } else { + gpio_direction_output(gpio_rst_req_n, 1); + s3c_gpio_setpull(gpio_rst_req_n, S3C_GPIO_PULL_NONE); + } + gpio_set_value(gpio_rst_req_n, 0); + } + + if (gpio_cp_rst) { + err = gpio_request(gpio_cp_rst, "ESC_RST"); + if (err) { + pr_err("fail to request gpio %s, gpio %d, errno %d\n", + "ESC_RST", gpio_cp_rst, err); + } else { + gpio_direction_output(gpio_cp_rst, 0); + s3c_gpio_setpull(gpio_cp_rst, S3C_GPIO_PULL_NONE); + s5p_gpio_set_drvstr(gpio_cp_rst, S5P_GPIO_DRVSTR_LV4); + } + gpio_set_value(gpio_cp_rst, 0); + } + + if (gpio_dpram_int) { + err = gpio_request(gpio_dpram_int, "ESC_DPRAM_INT"); + if (err) { + pr_err("fail to request gpio %s, gpio %d, errno %d\n", + "ESC_DPRAM_INT", gpio_dpram_int, err); + } else { + /* Configure as a wake-up source */ + s3c_gpio_cfgpin(gpio_dpram_int, S3C_GPIO_SFN(0xF)); + s3c_gpio_setpull(gpio_dpram_int, S3C_GPIO_PULL_NONE); + } + } + + err = gpio_request(EXYNOS4_GPA1(4), "AP_CP2_UART_RXD"); + if (err) { + pr_err("fail to request gpio %s, gpio %d, errno %d\n", + "AP_CP2_UART_RXD", EXYNOS4_GPA1(4), err); + } else { + s3c_gpio_cfgpin(EXYNOS4_GPA1(4), S3C_GPIO_SFN(0x2)); + s3c_gpio_setpull(EXYNOS4_GPA1(4), S3C_GPIO_PULL_NONE); + } + + err = gpio_request(EXYNOS4_GPA1(5), "AP_CP2_UART_TXD"); + if (err) { + pr_err("fail to request gpio %s, gpio %d, errno %d\n", + "AP_CP2_UART_TXD", EXYNOS4_GPA1(5), err); + } else { + s3c_gpio_cfgpin(EXYNOS4_GPA1(5), S3C_GPIO_SFN(0x2)); + s3c_gpio_setpull(EXYNOS4_GPA1(5), S3C_GPIO_PULL_NONE); + } + + if (gpio_sim_detect) { + err = gpio_request(gpio_sim_detect, "ESC_SIM_DETECT"); + if (err) { + pr_err("fail to request gpio %s: %d\n", + "ESC_SIM_DETECT", err); + } else { + /* gpio_direction_input(gpio_sim_detect); */ + s3c_gpio_cfgpin(gpio_sim_detect, S3C_GPIO_SFN(0xF)); + s3c_gpio_setpull(gpio_sim_detect, S3C_GPIO_PULL_NONE); + /* irq_set_irq_type(gpio_sim_detect, IRQ_TYPE_EDGE_BOTH); */ + } + } + +#if defined(CONFIG_LINK_DEVICE_PLD) + if (gpio_fpga1_creset) { + err = gpio_request(gpio_fpga1_creset, "FPGA1_CRESET"); + if (err) { + pr_err("fail to request gpio %s, gpio %d, errno %d\n", + "FPGA1_CRESET", gpio_fpga1_creset, err); + } else { + gpio_direction_output(gpio_fpga1_creset, 0); + s3c_gpio_setpull(gpio_fpga1_creset, S3C_GPIO_PULL_NONE); + } + } + + if (gpio_fpga1_cdone) { + err = gpio_request(gpio_fpga1_cdone, "FPGA1_CDONE"); + if (err) { + pr_err("fail to request gpio %s, gpio %d, errno %d\n", + "FPGA1_CDONE", gpio_fpga1_cdone, err); + } else { + s3c_gpio_cfgpin(gpio_fpga1_cdone, S3C_GPIO_INPUT); + s3c_gpio_setpull(gpio_fpga1_cdone, S3C_GPIO_PULL_NONE); + } + } + + if (gpio_fpga1_rst_n) { + err = gpio_request(gpio_fpga1_rst_n, "FPGA1_RST"); + if (err) { + pr_err("fail to request gpio %s, gpio %d, errno %d\n", + "FPGA1_RST", gpio_fpga1_rst_n, err); + } else { + gpio_direction_output(gpio_fpga1_rst_n, 0); + s3c_gpio_setpull(gpio_fpga1_rst_n, S3C_GPIO_PULL_NONE); + } + } + + if (gpio_fpga1_cs_n) { + err = gpio_request(gpio_fpga1_cs_n, "SPI_CS1_1"); + if (err) { + pr_err("fail to request gpio %s, gpio %d, errno %d\n", + "SPI_CS2_1", gpio_fpga1_cs_n, err); + } else { + gpio_direction_output(gpio_fpga1_cs_n, 0); + s3c_gpio_setpull(gpio_fpga1_cs_n, S3C_GPIO_PULL_NONE); + } + } +#endif } +static u8 *gsm_edpram_remap_mem_region(struct sromc_cfg *cfg) +{ + int dp_addr = 0; + int dp_size = 0; + u8 __iomem *dp_base = NULL; + struct msm_edpram_ipc_cfg *ipc_map = NULL; + struct dpram_ipc_device *dev = NULL; + + dp_addr = cfg->addr; + dp_size = cfg->size; + dp_base = (u8 *)ioremap_nocache(dp_addr, dp_size); + if (!dp_base) { + pr_err("[MDM] <%s> dpram base ioremap fail\n", __func__); + return NULL; + } + pr_info("[MDM] <%s> DPRAM VA=0x%08X\n", __func__, (int)dp_base); + + gsm_edpram_ctrl.dp_base = (u8 __iomem *)dp_base; + gsm_edpram_ctrl.dp_size = dp_size; + + /* Map for IPC */ + ipc_map = (struct msm_edpram_ipc_cfg *)dp_base; + + /* Magic code and access enable fields */ +#if defined(CONFIG_LINK_DEVICE_PLD) + /* Magic code and access enable fields */ + gsm_ipc_map.magic_ap2cp = (u16 __iomem *) &ipc_map->magic_ap2cp; + gsm_ipc_map.access_ap2cp = (u16 __iomem *) &ipc_map->access_ap2cp; + + gsm_ipc_map.magic_cp2ap = (u16 __iomem *) &ipc_map->magic_cp2ap; + gsm_ipc_map.access_cp2ap = (u16 __iomem *) &ipc_map->access_cp2ap; + + gsm_ipc_map.address_buffer = (u16 __iomem *) &ipc_map->address_buffer; +#else + /* Magic code and access enable fields */ + gsm_ipc_map.magic = (u16 __iomem *)&ipc_map->magic; + gsm_ipc_map.access = (u16 __iomem *)&ipc_map->access; +#endif + + /* FMT */ + dev = &gsm_ipc_map.dev[IPC_FMT]; + + strcpy(dev->name, "FMT"); + dev->id = IPC_FMT; + + dev->txq.head = (u16 __iomem *)&ipc_map->fmt_tx_head; + dev->txq.tail = (u16 __iomem *)&ipc_map->fmt_tx_tail; + dev->txq.buff = (u8 __iomem *)&ipc_map->fmt_tx_buff[0]; + dev->txq.size = MSM_DP_FMT_TX_BUFF_SZ; + + dev->rxq.head = (u16 __iomem *)&ipc_map->fmt_rx_head; + dev->rxq.tail = (u16 __iomem *)&ipc_map->fmt_rx_tail; + dev->rxq.buff = (u8 __iomem *)&ipc_map->fmt_rx_buff[0]; + dev->rxq.size = MSM_DP_FMT_RX_BUFF_SZ; + + dev->mask_req_ack = INT_MASK_REQ_ACK_F; + dev->mask_res_ack = INT_MASK_RES_ACK_F; + dev->mask_send = INT_MASK_SEND_F; + + /* RAW */ + dev = &gsm_ipc_map.dev[IPC_RAW]; + + strcpy(dev->name, "RAW"); + dev->id = IPC_RAW; + + dev->txq.head = (u16 __iomem *)&ipc_map->raw_tx_head; + dev->txq.tail = (u16 __iomem *)&ipc_map->raw_tx_tail; + dev->txq.buff = (u8 __iomem *)&ipc_map->raw_tx_buff[0]; + dev->txq.size = MSM_DP_RAW_TX_BUFF_SZ; + + dev->rxq.head = (u16 __iomem *)&ipc_map->raw_rx_head; + dev->rxq.tail = (u16 __iomem *)&ipc_map->raw_rx_tail; + dev->rxq.buff = (u8 __iomem *)&ipc_map->raw_rx_buff[0]; + dev->rxq.size = MSM_DP_RAW_RX_BUFF_SZ; + + dev->mask_req_ack = INT_MASK_REQ_ACK_R; + dev->mask_res_ack = INT_MASK_RES_ACK_R; + dev->mask_send = INT_MASK_SEND_R; + + /* Mailboxes */ + gsm_ipc_map.mbx_ap2cp = (u16 __iomem *)&ipc_map->mbx_ap2cp; + gsm_ipc_map.mbx_cp2ap = (u16 __iomem *)&ipc_map->mbx_cp2ap; + + return dp_base; +} +#endif + +#if defined(CONFIG_LINK_DEVICE_PLD) +#define PLD_BLOCK_SIZE 0x8000 + +static struct spi_device *p_spi; + +static int pld_spi_probe(struct spi_device *spi) +{ + int ret = 0; + + mif_err("pld spi proble.\n"); + + p_spi = spi; + p_spi->mode = SPI_MODE_0; + p_spi->bits_per_word = 32; + + ret = spi_setup(p_spi); + if (ret != 0) { + mif_err("spi_setup ERROR : %d\n", ret); + return ret; + } + + dev_info(&p_spi->dev, "(%d) spi probe Done.\n", __LINE__); + + return ret; +} + +static int pld_spi_remove(struct spi_device *spi) +{ + return 0; +} + +static struct spi_driver pld_spi_driver = { + .probe = pld_spi_probe, + .remove = __devexit_p(pld_spi_remove), + .driver = { + .name = "modem_if_spi", + .bus = &spi_bus_type, + .owner = THIS_MODULE, + }, +}; + +static int config_spi_dev_init(void) +{ + int ret = 0; + + ret = spi_register_driver(&pld_spi_driver); + if (ret < 0) { + pr_info("spi_register_driver() fail : %d\n", ret); + return ret; + } + + pr_info("[%s] Done\n", __func__); + return 0; +} + +int spi_tx_rx_sync(u8 *tx_d, u8 *rx_d, unsigned len) +{ + struct spi_transfer t; + struct spi_message msg; + + memset(&t, 0, sizeof t); + + t.len = len; + + t.tx_buf = tx_d; + t.rx_buf = rx_d; + + t.cs_change = 0; + + t.bits_per_word = 8; + t.speed_hz = 12000000; + + spi_message_init(&msg); + spi_message_add_tail(&t, &msg); + + return spi_sync(p_spi, &msg); +} + +static int pld_send_fgpa_bin(void) +{ + int retval = 0; + char *tx_b, *rx_b; +#if defined(CONFIG_LINK_DEVICE_PLD) + unsigned gpio_fpga1_creset = gsm_modem_data.gpio_fpga1_creset; + unsigned gpio_fpga1_cdone = gsm_modem_data.gpio_fpga1_cdone; + unsigned gpio_fpga1_rst_n = gsm_modem_data.gpio_fpga1_rst_n; + unsigned gpio_fpga1_cs_n = gsm_modem_data.gpio_fpga1_cs_n; + + unsigned gpio_fpga2_creset = cdma_modem_data.gpio_fpga2_creset; + unsigned gpio_fpga2_cdone = cdma_modem_data.gpio_fpga2_cdone; + unsigned gpio_fpga2_rst_n = cdma_modem_data.gpio_fpga2_rst_n; + unsigned gpio_fpga2_cs_n = cdma_modem_data.gpio_fpga2_cs_n; +#endif + char dummy_data[8] = "abcdefg"; + + mif_info("sizeofpld : 0%d ", sizeof(fpga_bin)); + + if (gpio_fpga1_cs_n) { + s3c_gpio_cfgpin(gpio_fpga1_cs_n, S3C_GPIO_OUTPUT); + s3c_gpio_setpull(gpio_fpga1_cs_n, S3C_GPIO_PULL_NONE); + gpio_direction_output(gpio_fpga1_cs_n, 0); + } + + if (gpio_fpga2_cs_n) { + s3c_gpio_cfgpin(gpio_fpga2_cs_n, S3C_GPIO_OUTPUT); + s3c_gpio_setpull(gpio_fpga2_cs_n, S3C_GPIO_PULL_NONE); + gpio_direction_output(gpio_fpga2_cs_n, 0); + } + + msleep(20); + + if (gpio_fpga1_creset) { + gpio_direction_output(gpio_fpga1_creset, 1); + s3c_gpio_setpull(gpio_fpga1_creset, S3C_GPIO_PULL_NONE); + } + + if (gpio_fpga2_creset) { + gpio_direction_output(gpio_fpga2_creset, 1); + s3c_gpio_setpull(gpio_fpga2_creset, S3C_GPIO_PULL_NONE); + } + + msleep(20); + + tx_b = kmalloc(PLD_BLOCK_SIZE*2, GFP_ATOMIC); + if (!tx_b) { + mif_err("(%d) tx_b kmalloc fail.", + __LINE__); + return -ENOMEM; + } + memset(tx_b, 0, PLD_BLOCK_SIZE*2); + memcpy(tx_b, fpga_bin, sizeof(fpga_bin)); + + rx_b = kmalloc(PLD_BLOCK_SIZE*2, GFP_ATOMIC); + if (!rx_b) { + mif_err("(%d) rx_b kmalloc fail.", + __LINE__); + retval = -ENOMEM; + goto err; + } + memset(rx_b, 0, PLD_BLOCK_SIZE*2); + + retval = spi_tx_rx_sync(tx_b, rx_b, sizeof(fpga_bin)); + if (retval != 0) { + mif_err("(%d) spi sync error : %d\n", + __LINE__, retval); + goto err; + } + + memset(tx_b, 0, PLD_BLOCK_SIZE*2); + memcpy(tx_b, dummy_data, sizeof(dummy_data)); + + retval = spi_tx_rx_sync(tx_b, rx_b, sizeof(dummy_data)); + if (retval != 0) { + mif_err("(%d) spi sync error : %d\n", + __LINE__, retval); + goto err; + } + + msleep(20); + + mif_info("PLD_CDone1[%d], PLD_CDone2[%d]\n", + gpio_get_value(gpio_fpga1_cdone), + gpio_get_value(gpio_fpga2_cdone)); + + if (gpio_fpga1_rst_n) { + gpio_direction_output(gpio_fpga1_rst_n, 1); + s3c_gpio_setpull(gpio_fpga1_rst_n, S3C_GPIO_PULL_NONE); + } + + if (gpio_fpga2_rst_n) { + gpio_direction_output(gpio_fpga2_rst_n, 1); + s3c_gpio_setpull(gpio_fpga2_rst_n, S3C_GPIO_PULL_NONE); + } + +err: + kfree(tx_b); + kfree(rx_b); + + return retval; + +} +#endif + static int __init init_modem(void) { struct sromc_cfg *cfg = NULL; struct sromc_access_cfg *acc_cfg = NULL; +#if defined(CONFIG_MACH_T0_CHN_CTC) + msm_edpram_cfg.csn = 1; +#else msm_edpram_cfg.csn = 0; +#endif msm_edpram_cfg.addr = SROM_CS0_BASE + (SROM_WIDTH * msm_edpram_cfg.csn); msm_edpram_cfg.end = msm_edpram_cfg.addr + msm_edpram_cfg.size - 1; config_dpram_port_gpio(); config_cdma_modem_gpio(); +#if defined(CONFIG_GSM_MODEM_ESC6270) + config_gsm_modem_gpio(); +#endif + +#if defined(CONFIG_LINK_DEVICE_PLD) + config_spi_dev_init(); + pld_send_fgpa_bin(); +#endif init_sromc(); cfg = &msm_edpram_cfg; @@ -1594,6 +2028,26 @@ static int __init init_modem(void) return -1; platform_device_register(&cdma_modem); +/* For ESC6270 modem */ +#if defined(CONFIG_GSM_MODEM_ESC6270) + +#if defined(CONFIG_MACH_T0_CHN_CTC) + gsm_edpram_cfg.csn = 0; +#else + gsm_edpram_cfg.csn = 1; +#endif + gsm_edpram_cfg.addr = SROM_CS0_BASE + (SROM_WIDTH * gsm_edpram_cfg.csn); + gsm_edpram_cfg.end = gsm_edpram_cfg.addr + gsm_edpram_cfg.size - 1; + + cfg = &gsm_edpram_cfg; + acc_cfg = &gsm_edpram_access_cfg[DPRAM_SPEED_LOW]; + setup_sromc(cfg->csn, cfg, acc_cfg); + + if (!gsm_edpram_remap_mem_region(&gsm_edpram_cfg)) + return -1; + + platform_device_register(&gsm_modem); +#endif return 0; } @@ -1639,7 +2093,7 @@ static int usb3503_hw_config(void) if (err) { pr_err("fail to request gpio %s\n", "USB_BOOT_EN"); } else { - gpio_direction_output(GPIO_USB_BOOT_EN, 1); + gpio_direction_output(GPIO_USB_BOOT_EN, 0); s3c_gpio_setpull(GPIO_USB_BOOT_EN, S3C_GPIO_PULL_NONE); } } else if (system_rev == 11) { @@ -1647,7 +2101,7 @@ static int usb3503_hw_config(void) if (err) { pr_err("fail to request gpio %s\n", "USB_BOOT_EN"); } else { - gpio_direction_output(GPIO_USB_BOOT_EN, 1); + gpio_direction_output(GPIO_USB_BOOT_EN, 0); s3c_gpio_setpull(GPIO_USB_BOOT_EN, S3C_GPIO_PULL_NONE); } err = gpio_request(GPIO_USB_BOOT_EN_REV06, "USB_BOOT_EN_REV06"); @@ -1655,7 +2109,7 @@ static int usb3503_hw_config(void) pr_err("fail to request gpio %s\n", "USB_BOOT_EN_REV06"); } else { - gpio_direction_output(GPIO_USB_BOOT_EN_REV06, 1); + gpio_direction_output(GPIO_USB_BOOT_EN_REV06, 0); s3c_gpio_setpull(GPIO_USB_BOOT_EN_REV06, S3C_GPIO_PULL_NONE); } @@ -1665,7 +2119,7 @@ static int usb3503_hw_config(void) pr_err("fail to request gpio %s\n", "USB_BOOT_EN_REV06"); } else { - gpio_direction_output(GPIO_USB_BOOT_EN_REV06, 1); + gpio_direction_output(GPIO_USB_BOOT_EN_REV06, 0); s3c_gpio_setpull(GPIO_USB_BOOT_EN_REV06, S3C_GPIO_PULL_NONE); } @@ -1752,7 +2206,7 @@ device_initcall(init_usbhub); static int host_port_enable(int port, int enable) { - int err, retry = 30; + int err; pr_info("[MDM] <%s> port(%d) control(%d)\n", __func__, port, enable); |