Michael Krufky | 1c11d54 | 2008-06-18 22:09:55 -0300 | [diff] [blame] | 1 | /* |
| 2 | * Card-specific functions for the Siano SMS1xxx USB dongle |
| 3 | * |
| 4 | * Copyright (c) 2008 Michael Krufky <mkrufky@linuxtv.org> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
Michael Krufky | 09a29b7 | 2008-09-03 16:48:17 -0300 | [diff] [blame] | 7 | * it under the terms of the GNU General Public License version 2 as |
Michael Krufky | 1c11d54 | 2008-06-18 22:09:55 -0300 | [diff] [blame] | 8 | * published by the Free Software Foundation; |
| 9 | * |
| 10 | * Software distributed under the License is distributed on an "AS IS" |
| 11 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. |
| 12 | * |
| 13 | * See the GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 18 | */ |
| 19 | |
| 20 | #include "sms-cards.h" |
Uri Shkolnik | 90f944a | 2009-05-14 16:32:12 -0300 | [diff] [blame] | 21 | #include "smsir.h" |
Paul Gortmaker | 7a707b8 | 2011-07-03 14:03:12 -0400 | [diff] [blame] | 22 | #include <linux/module.h> |
Michael Krufky | 1c11d54 | 2008-06-18 22:09:55 -0300 | [diff] [blame] | 23 | |
Michael Krufky | 0d02efe | 2009-02-27 02:42:16 -0300 | [diff] [blame] | 24 | static int sms_dbg; |
| 25 | module_param_named(cards_dbg, sms_dbg, int, 0644); |
| 26 | MODULE_PARM_DESC(cards_dbg, "set debug level (info=1, adv=2 (or-able))"); |
| 27 | |
Michael Krufky | 1c11d54 | 2008-06-18 22:09:55 -0300 | [diff] [blame] | 28 | static struct sms_board sms_boards[] = { |
| 29 | [SMS_BOARD_UNKNOWN] = { |
| 30 | .name = "Unknown board", |
Mauro Carvalho Chehab | 347d8f1 | 2013-03-05 22:35:44 -0300 | [diff] [blame] | 31 | .type = SMS_UNKNOWN_TYPE, |
| 32 | .default_mode = DEVICE_MODE_NONE, |
Michael Krufky | 1c11d54 | 2008-06-18 22:09:55 -0300 | [diff] [blame] | 33 | }, |
Michael Krufky | 1c11d54 | 2008-06-18 22:09:55 -0300 | [diff] [blame] | 34 | [SMS1XXX_BOARD_SIANO_STELLAR] = { |
Michael Krufky | cf1cfe1 | 2008-06-28 16:45:36 -0300 | [diff] [blame] | 35 | .name = "Siano Stellar Digital Receiver", |
Michael Krufky | 1c11d54 | 2008-06-18 22:09:55 -0300 | [diff] [blame] | 36 | .type = SMS_STELLAR, |
Mauro Carvalho Chehab | 347d8f1 | 2013-03-05 22:35:44 -0300 | [diff] [blame] | 37 | .default_mode = DEVICE_MODE_DVBT_BDA, |
Michael Krufky | 1c11d54 | 2008-06-18 22:09:55 -0300 | [diff] [blame] | 38 | }, |
| 39 | [SMS1XXX_BOARD_SIANO_NOVA_A] = { |
Michael Krufky | cf1cfe1 | 2008-06-28 16:45:36 -0300 | [diff] [blame] | 40 | .name = "Siano Nova A Digital Receiver", |
Michael Krufky | 1c11d54 | 2008-06-18 22:09:55 -0300 | [diff] [blame] | 41 | .type = SMS_NOVA_A0, |
Mauro Carvalho Chehab | 347d8f1 | 2013-03-05 22:35:44 -0300 | [diff] [blame] | 42 | .default_mode = DEVICE_MODE_DVBT_BDA, |
Michael Krufky | 1c11d54 | 2008-06-18 22:09:55 -0300 | [diff] [blame] | 43 | }, |
| 44 | [SMS1XXX_BOARD_SIANO_NOVA_B] = { |
Michael Krufky | cf1cfe1 | 2008-06-28 16:45:36 -0300 | [diff] [blame] | 45 | .name = "Siano Nova B Digital Receiver", |
Michael Krufky | 1c11d54 | 2008-06-18 22:09:55 -0300 | [diff] [blame] | 46 | .type = SMS_NOVA_B0, |
Mauro Carvalho Chehab | 347d8f1 | 2013-03-05 22:35:44 -0300 | [diff] [blame] | 47 | .default_mode = DEVICE_MODE_DVBT_BDA, |
Michael Krufky | 1c11d54 | 2008-06-18 22:09:55 -0300 | [diff] [blame] | 48 | }, |
| 49 | [SMS1XXX_BOARD_SIANO_VEGA] = { |
Michael Krufky | cf1cfe1 | 2008-06-28 16:45:36 -0300 | [diff] [blame] | 50 | .name = "Siano Vega Digital Receiver", |
Michael Krufky | 1c11d54 | 2008-06-18 22:09:55 -0300 | [diff] [blame] | 51 | .type = SMS_VEGA, |
Mauro Carvalho Chehab | 347d8f1 | 2013-03-05 22:35:44 -0300 | [diff] [blame] | 52 | .default_mode = DEVICE_MODE_CMMB, |
Michael Krufky | 1c11d54 | 2008-06-18 22:09:55 -0300 | [diff] [blame] | 53 | }, |
Michael Krufky | 44f71c3 | 2008-06-28 23:55:36 -0300 | [diff] [blame] | 54 | [SMS1XXX_BOARD_HAUPPAUGE_CATAMOUNT] = { |
| 55 | .name = "Hauppauge Catamount", |
| 56 | .type = SMS_STELLAR, |
Mauro Carvalho Chehab | 11ad03a | 2013-03-19 17:02:54 -0300 | [diff] [blame] | 57 | .fw[DEVICE_MODE_DVBT_BDA] = SMS_FW_DVBT_STELLAR, |
Mauro Carvalho Chehab | 347d8f1 | 2013-03-05 22:35:44 -0300 | [diff] [blame] | 58 | .default_mode = DEVICE_MODE_DVBT_BDA, |
Michael Krufky | 44f71c3 | 2008-06-28 23:55:36 -0300 | [diff] [blame] | 59 | }, |
| 60 | [SMS1XXX_BOARD_HAUPPAUGE_OKEMO_A] = { |
| 61 | .name = "Hauppauge Okemo-A", |
| 62 | .type = SMS_NOVA_A0, |
Mauro Carvalho Chehab | 11ad03a | 2013-03-19 17:02:54 -0300 | [diff] [blame] | 63 | .fw[DEVICE_MODE_DVBT_BDA] = SMS_FW_DVBT_NOVA_A, |
Mauro Carvalho Chehab | 347d8f1 | 2013-03-05 22:35:44 -0300 | [diff] [blame] | 64 | .default_mode = DEVICE_MODE_DVBT_BDA, |
Michael Krufky | 44f71c3 | 2008-06-28 23:55:36 -0300 | [diff] [blame] | 65 | }, |
| 66 | [SMS1XXX_BOARD_HAUPPAUGE_OKEMO_B] = { |
| 67 | .name = "Hauppauge Okemo-B", |
| 68 | .type = SMS_NOVA_B0, |
Mauro Carvalho Chehab | 11ad03a | 2013-03-19 17:02:54 -0300 | [diff] [blame] | 69 | .fw[DEVICE_MODE_DVBT_BDA] = SMS_FW_DVBT_NOVA_B, |
Mauro Carvalho Chehab | 347d8f1 | 2013-03-05 22:35:44 -0300 | [diff] [blame] | 70 | .default_mode = DEVICE_MODE_DVBT_BDA, |
Michael Krufky | 44f71c3 | 2008-06-28 23:55:36 -0300 | [diff] [blame] | 71 | }, |
| 72 | [SMS1XXX_BOARD_HAUPPAUGE_WINDHAM] = { |
Michael Krufky | 7a9b5fc | 2008-09-11 23:02:12 -0300 | [diff] [blame] | 73 | .name = "Hauppauge WinTV MiniStick", |
Michael Krufky | 44f71c3 | 2008-06-28 23:55:36 -0300 | [diff] [blame] | 74 | .type = SMS_NOVA_B0, |
Mauro Carvalho Chehab | 11ad03a | 2013-03-19 17:02:54 -0300 | [diff] [blame] | 75 | .fw[DEVICE_MODE_ISDBT_BDA] = SMS_FW_ISDBT_HCW_55XXX, |
| 76 | .fw[DEVICE_MODE_DVBT_BDA] = SMS_FW_DVBT_HCW_55XXX, |
Mauro Carvalho Chehab | 347d8f1 | 2013-03-05 22:35:44 -0300 | [diff] [blame] | 77 | .default_mode = DEVICE_MODE_DVBT_BDA, |
Mauro Carvalho Chehab | 15195d3 | 2011-01-24 12:18:47 -0300 | [diff] [blame] | 78 | .rc_codes = RC_MAP_HAUPPAUGE, |
Uri Shkolnik | 9504cca | 2009-05-14 16:34:59 -0300 | [diff] [blame] | 79 | .board_cfg.leds_power = 26, |
| 80 | .board_cfg.led0 = 27, |
| 81 | .board_cfg.led1 = 28, |
Mauro Carvalho Chehab | 20d6444 | 2010-08-01 13:01:40 -0300 | [diff] [blame] | 82 | .board_cfg.ir = 9, |
Michael Krufky | 250fa67 | 2008-11-16 22:45:42 -0300 | [diff] [blame] | 83 | .led_power = 26, |
| 84 | .led_lo = 27, |
| 85 | .led_hi = 28, |
Michael Krufky | 44f71c3 | 2008-06-28 23:55:36 -0300 | [diff] [blame] | 86 | }, |
Michael Krufky | 3f7d99f | 2008-11-22 11:21:02 -0300 | [diff] [blame] | 87 | [SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD] = { |
| 88 | .name = "Hauppauge WinTV MiniCard", |
| 89 | .type = SMS_NOVA_B0, |
Mauro Carvalho Chehab | 11ad03a | 2013-03-19 17:02:54 -0300 | [diff] [blame] | 90 | .fw[DEVICE_MODE_DVBT_BDA] = SMS_FW_DVBT_HCW_55XXX, |
Mauro Carvalho Chehab | 347d8f1 | 2013-03-05 22:35:44 -0300 | [diff] [blame] | 91 | .default_mode = DEVICE_MODE_DVBT_BDA, |
Michael Krufky | 250fa67 | 2008-11-16 22:45:42 -0300 | [diff] [blame] | 92 | .lna_ctrl = 29, |
Uri Shkolnik | 9504cca | 2009-05-14 16:34:59 -0300 | [diff] [blame] | 93 | .board_cfg.foreign_lna0_ctrl = 29, |
Michael Krufky | d54093a | 2008-12-16 02:56:08 -0300 | [diff] [blame] | 94 | .rf_switch = 17, |
Uri Shkolnik | 9504cca | 2009-05-14 16:34:59 -0300 | [diff] [blame] | 95 | .board_cfg.rf_switch_uhf = 17, |
Michael Krufky | 250fa67 | 2008-11-16 22:45:42 -0300 | [diff] [blame] | 96 | }, |
| 97 | [SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2] = { |
| 98 | .name = "Hauppauge WinTV MiniCard", |
| 99 | .type = SMS_NOVA_B0, |
Mauro Carvalho Chehab | 11ad03a | 2013-03-19 17:02:54 -0300 | [diff] [blame] | 100 | .fw[DEVICE_MODE_DVBT_BDA] = SMS_FW_DVBT_HCW_55XXX, |
Mauro Carvalho Chehab | 347d8f1 | 2013-03-05 22:35:44 -0300 | [diff] [blame] | 101 | .default_mode = DEVICE_MODE_DVBT_BDA, |
Michael Krufky | f4c8254 | 2008-12-15 17:28:41 -0300 | [diff] [blame] | 102 | .lna_ctrl = -1, |
Michael Krufky | 3f7d99f | 2008-11-22 11:21:02 -0300 | [diff] [blame] | 103 | }, |
Uri Shkolnik | d0b66180 | 2009-05-19 09:51:41 -0300 | [diff] [blame] | 104 | [SMS1XXX_BOARD_SIANO_NICE] = { |
Uri Shkolnik | d0b66180 | 2009-05-19 09:51:41 -0300 | [diff] [blame] | 105 | .name = "Siano Nice Digital Receiver", |
| 106 | .type = SMS_NOVA_B0, |
Mauro Carvalho Chehab | 347d8f1 | 2013-03-05 22:35:44 -0300 | [diff] [blame] | 107 | .default_mode = DEVICE_MODE_DVBT_BDA, |
Uri Shkolnik | d0b66180 | 2009-05-19 09:51:41 -0300 | [diff] [blame] | 108 | }, |
| 109 | [SMS1XXX_BOARD_SIANO_VENICE] = { |
Uri Shkolnik | d0b66180 | 2009-05-19 09:51:41 -0300 | [diff] [blame] | 110 | .name = "Siano Venice Digital Receiver", |
| 111 | .type = SMS_VEGA, |
Mauro Carvalho Chehab | 347d8f1 | 2013-03-05 22:35:44 -0300 | [diff] [blame] | 112 | .default_mode = DEVICE_MODE_CMMB, |
| 113 | }, |
| 114 | [SMS1XXX_BOARD_SIANO_STELLAR_ROM] = { |
| 115 | .name = "Siano Stellar Digital Receiver ROM", |
| 116 | .type = SMS_STELLAR, |
| 117 | .default_mode = DEVICE_MODE_DVBT_BDA, |
| 118 | .intf_num = 1, |
| 119 | }, |
| 120 | [SMS1XXX_BOARD_ZTE_DVB_DATA_CARD] = { |
| 121 | .name = "ZTE Data Card Digital Receiver", |
| 122 | .type = SMS_NOVA_B0, |
| 123 | .default_mode = DEVICE_MODE_DVBT_BDA, |
| 124 | .intf_num = 5, |
| 125 | .mtu = 15792, |
| 126 | }, |
| 127 | [SMS1XXX_BOARD_ONDA_MDTV_DATA_CARD] = { |
| 128 | .name = "ONDA Data Card Digital Receiver", |
| 129 | .type = SMS_NOVA_B0, |
| 130 | .default_mode = DEVICE_MODE_DVBT_BDA, |
| 131 | .intf_num = 6, |
| 132 | .mtu = 15792, |
| 133 | }, |
| 134 | [SMS1XXX_BOARD_SIANO_MING] = { |
| 135 | .name = "Siano Ming Digital Receiver", |
| 136 | .type = SMS_MING, |
| 137 | .default_mode = DEVICE_MODE_CMMB, |
| 138 | }, |
| 139 | [SMS1XXX_BOARD_SIANO_PELE] = { |
| 140 | .name = "Siano Pele Digital Receiver", |
| 141 | .type = SMS_PELE, |
| 142 | .default_mode = DEVICE_MODE_ISDBT_BDA, |
| 143 | }, |
| 144 | [SMS1XXX_BOARD_SIANO_RIO] = { |
| 145 | .name = "Siano Rio Digital Receiver", |
| 146 | .type = SMS_RIO, |
| 147 | .default_mode = DEVICE_MODE_ISDBT_BDA, |
| 148 | }, |
| 149 | [SMS1XXX_BOARD_SIANO_DENVER_1530] = { |
| 150 | .name = "Siano Denver (ATSC-M/H) Digital Receiver", |
| 151 | .type = SMS_DENVER_1530, |
| 152 | .default_mode = DEVICE_MODE_ATSC, |
| 153 | .crystal = 2400, |
| 154 | }, |
| 155 | [SMS1XXX_BOARD_SIANO_DENVER_2160] = { |
| 156 | .name = "Siano Denver (TDMB) Digital Receiver", |
| 157 | .type = SMS_DENVER_2160, |
| 158 | .default_mode = DEVICE_MODE_DAB_TDMB, |
Uri Shkolnik | d0b66180 | 2009-05-19 09:51:41 -0300 | [diff] [blame] | 159 | }, |
Michael Krufky | 1c11d54 | 2008-06-18 22:09:55 -0300 | [diff] [blame] | 160 | }; |
| 161 | |
Roel Kluin | 3a05462 | 2009-11-17 19:43:40 -0300 | [diff] [blame] | 162 | struct sms_board *sms_get_board(unsigned id) |
Michael Krufky | 1c11d54 | 2008-06-18 22:09:55 -0300 | [diff] [blame] | 163 | { |
| 164 | BUG_ON(id >= ARRAY_SIZE(sms_boards)); |
| 165 | |
| 166 | return &sms_boards[id]; |
| 167 | } |
Michael Krufky | a0beec8 | 2009-02-26 18:32:36 -0300 | [diff] [blame] | 168 | EXPORT_SYMBOL_GPL(sms_get_board); |
Uri Shkolnik | 5b8db89 | 2009-05-19 12:18:40 -0300 | [diff] [blame] | 169 | static inline void sms_gpio_assign_11xx_default_led_config( |
Mauro Carvalho Chehab | dfef84f | 2013-03-21 08:49:43 -0300 | [diff] [blame] | 170 | struct smscore_config_gpio *p_gpio_config) { |
| 171 | p_gpio_config->direction = SMS_GPIO_DIRECTION_OUTPUT; |
| 172 | p_gpio_config->inputcharacteristics = |
Mauro Carvalho Chehab | c31b9fb | 2013-03-06 08:30:08 -0300 | [diff] [blame] | 173 | SMS_GPIO_INPUTCHARACTERISTICS_NORMAL; |
Mauro Carvalho Chehab | dfef84f | 2013-03-21 08:49:43 -0300 | [diff] [blame] | 174 | p_gpio_config->outputdriving = SMS_GPIO_OUTPUTDRIVING_4mA; |
| 175 | p_gpio_config->outputslewrate = SMS_GPIO_OUTPUT_SLEW_RATE_0_45_V_NS; |
| 176 | p_gpio_config->pullupdown = SMS_GPIO_PULLUPDOWN_NONE; |
Uri Shkolnik | 5b8db89 | 2009-05-19 12:18:40 -0300 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | int sms_board_event(struct smscore_device_t *coredev, |
Mauro Carvalho Chehab | 347d8f1 | 2013-03-05 22:35:44 -0300 | [diff] [blame] | 180 | enum SMS_BOARD_EVENTS gevent) |
| 181 | { |
Mauro Carvalho Chehab | 28a59df | 2013-03-21 09:27:37 -0300 | [diff] [blame] | 182 | struct smscore_config_gpio my_gpio_config; |
Uri Shkolnik | 5b8db89 | 2009-05-19 12:18:40 -0300 | [diff] [blame] | 183 | |
Mauro Carvalho Chehab | 28a59df | 2013-03-21 09:27:37 -0300 | [diff] [blame] | 184 | sms_gpio_assign_11xx_default_led_config(&my_gpio_config); |
Uri Shkolnik | 5b8db89 | 2009-05-19 12:18:40 -0300 | [diff] [blame] | 185 | |
| 186 | switch (gevent) { |
| 187 | case BOARD_EVENT_POWER_INIT: /* including hotplug */ |
Uri Shkolnik | 5b8db89 | 2009-05-19 12:18:40 -0300 | [diff] [blame] | 188 | break; /* BOARD_EVENT_BIND */ |
| 189 | |
| 190 | case BOARD_EVENT_POWER_SUSPEND: |
Uri Shkolnik | 5b8db89 | 2009-05-19 12:18:40 -0300 | [diff] [blame] | 191 | break; /* BOARD_EVENT_POWER_SUSPEND */ |
| 192 | |
| 193 | case BOARD_EVENT_POWER_RESUME: |
Uri Shkolnik | 5b8db89 | 2009-05-19 12:18:40 -0300 | [diff] [blame] | 194 | break; /* BOARD_EVENT_POWER_RESUME */ |
| 195 | |
| 196 | case BOARD_EVENT_BIND: |
Uri Shkolnik | 5b8db89 | 2009-05-19 12:18:40 -0300 | [diff] [blame] | 197 | break; /* BOARD_EVENT_BIND */ |
| 198 | |
| 199 | case BOARD_EVENT_SCAN_PROG: |
| 200 | break; /* BOARD_EVENT_SCAN_PROG */ |
| 201 | case BOARD_EVENT_SCAN_COMP: |
| 202 | break; /* BOARD_EVENT_SCAN_COMP */ |
| 203 | case BOARD_EVENT_EMERGENCY_WARNING_SIGNAL: |
| 204 | break; /* BOARD_EVENT_EMERGENCY_WARNING_SIGNAL */ |
| 205 | case BOARD_EVENT_FE_LOCK: |
Uri Shkolnik | 5b8db89 | 2009-05-19 12:18:40 -0300 | [diff] [blame] | 206 | break; /* BOARD_EVENT_FE_LOCK */ |
| 207 | case BOARD_EVENT_FE_UNLOCK: |
Uri Shkolnik | 5b8db89 | 2009-05-19 12:18:40 -0300 | [diff] [blame] | 208 | break; /* BOARD_EVENT_FE_UNLOCK */ |
| 209 | case BOARD_EVENT_DEMOD_LOCK: |
| 210 | break; /* BOARD_EVENT_DEMOD_LOCK */ |
| 211 | case BOARD_EVENT_DEMOD_UNLOCK: |
| 212 | break; /* BOARD_EVENT_DEMOD_UNLOCK */ |
| 213 | case BOARD_EVENT_RECEPTION_MAX_4: |
| 214 | break; /* BOARD_EVENT_RECEPTION_MAX_4 */ |
| 215 | case BOARD_EVENT_RECEPTION_3: |
| 216 | break; /* BOARD_EVENT_RECEPTION_3 */ |
| 217 | case BOARD_EVENT_RECEPTION_2: |
| 218 | break; /* BOARD_EVENT_RECEPTION_2 */ |
| 219 | case BOARD_EVENT_RECEPTION_1: |
| 220 | break; /* BOARD_EVENT_RECEPTION_1 */ |
| 221 | case BOARD_EVENT_RECEPTION_LOST_0: |
| 222 | break; /* BOARD_EVENT_RECEPTION_LOST_0 */ |
| 223 | case BOARD_EVENT_MULTIPLEX_OK: |
Uri Shkolnik | 5b8db89 | 2009-05-19 12:18:40 -0300 | [diff] [blame] | 224 | break; /* BOARD_EVENT_MULTIPLEX_OK */ |
| 225 | case BOARD_EVENT_MULTIPLEX_ERRORS: |
Uri Shkolnik | 5b8db89 | 2009-05-19 12:18:40 -0300 | [diff] [blame] | 226 | break; /* BOARD_EVENT_MULTIPLEX_ERRORS */ |
| 227 | |
| 228 | default: |
| 229 | sms_err("Unknown SMS board event"); |
| 230 | break; |
| 231 | } |
| 232 | return 0; |
| 233 | } |
| 234 | EXPORT_SYMBOL_GPL(sms_board_event); |
Michael Krufky | 1c11d54 | 2008-06-18 22:09:55 -0300 | [diff] [blame] | 235 | |
Michael Krufky | dd72f31 | 2008-11-28 01:02:56 -0300 | [diff] [blame] | 236 | static int sms_set_gpio(struct smscore_device_t *coredev, int pin, int enable) |
Michael Krufky | 250fa67 | 2008-11-16 22:45:42 -0300 | [diff] [blame] | 237 | { |
Michael Krufky | dd72f31 | 2008-11-28 01:02:56 -0300 | [diff] [blame] | 238 | int lvl, ret; |
| 239 | u32 gpio; |
Uri Shkolnik | 7c4ca79 | 2009-05-19 11:49:19 -0300 | [diff] [blame] | 240 | struct smscore_config_gpio gpioconfig = { |
Michael Krufky | 250fa67 | 2008-11-16 22:45:42 -0300 | [diff] [blame] | 241 | .direction = SMS_GPIO_DIRECTION_OUTPUT, |
| 242 | .pullupdown = SMS_GPIO_PULLUPDOWN_NONE, |
| 243 | .inputcharacteristics = SMS_GPIO_INPUTCHARACTERISTICS_NORMAL, |
Mauro Carvalho Chehab | c31b9fb | 2013-03-06 08:30:08 -0300 | [diff] [blame] | 244 | .outputslewrate = SMS_GPIO_OUTPUT_SLEW_RATE_FAST, |
Mauro Carvalho Chehab | f82757d | 2013-03-06 07:09:54 -0300 | [diff] [blame] | 245 | .outputdriving = SMS_GPIO_OUTPUTDRIVING_S_4mA, |
Michael Krufky | 250fa67 | 2008-11-16 22:45:42 -0300 | [diff] [blame] | 246 | }; |
| 247 | |
| 248 | if (pin == 0) |
| 249 | return -EINVAL; |
| 250 | |
Michael Krufky | dd72f31 | 2008-11-28 01:02:56 -0300 | [diff] [blame] | 251 | if (pin < 0) { |
| 252 | /* inverted gpio */ |
| 253 | gpio = pin * -1; |
| 254 | lvl = enable ? 0 : 1; |
| 255 | } else { |
| 256 | gpio = pin; |
| 257 | lvl = enable ? 1 : 0; |
| 258 | } |
Michael Krufky | 250fa67 | 2008-11-16 22:45:42 -0300 | [diff] [blame] | 259 | |
Michael Krufky | dd72f31 | 2008-11-28 01:02:56 -0300 | [diff] [blame] | 260 | ret = smscore_configure_gpio(coredev, gpio, &gpioconfig); |
Michael Krufky | 250fa67 | 2008-11-16 22:45:42 -0300 | [diff] [blame] | 261 | if (ret < 0) |
| 262 | return ret; |
| 263 | |
Michael Krufky | dd72f31 | 2008-11-28 01:02:56 -0300 | [diff] [blame] | 264 | return smscore_set_gpio(coredev, gpio, lvl); |
Michael Krufky | 250fa67 | 2008-11-16 22:45:42 -0300 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | int sms_board_setup(struct smscore_device_t *coredev) |
| 268 | { |
| 269 | int board_id = smscore_get_board_id(coredev); |
| 270 | struct sms_board *board = sms_get_board(board_id); |
| 271 | |
| 272 | switch (board_id) { |
| 273 | case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM: |
| 274 | /* turn off all LEDs */ |
| 275 | sms_set_gpio(coredev, board->led_power, 0); |
| 276 | sms_set_gpio(coredev, board->led_hi, 0); |
| 277 | sms_set_gpio(coredev, board->led_lo, 0); |
| 278 | break; |
Michael Krufky | dff6574 | 2008-11-22 14:33:00 -0300 | [diff] [blame] | 279 | case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2: |
| 280 | case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD: |
| 281 | /* turn off LNA */ |
| 282 | sms_set_gpio(coredev, board->lna_ctrl, 0); |
| 283 | break; |
Michael Krufky | 250fa67 | 2008-11-16 22:45:42 -0300 | [diff] [blame] | 284 | } |
| 285 | return 0; |
| 286 | } |
Michael Krufky | a0beec8 | 2009-02-26 18:32:36 -0300 | [diff] [blame] | 287 | EXPORT_SYMBOL_GPL(sms_board_setup); |
Michael Krufky | 7a6fbed | 2008-11-22 14:26:37 -0300 | [diff] [blame] | 288 | |
| 289 | int sms_board_power(struct smscore_device_t *coredev, int onoff) |
| 290 | { |
| 291 | int board_id = smscore_get_board_id(coredev); |
| 292 | struct sms_board *board = sms_get_board(board_id); |
| 293 | |
| 294 | switch (board_id) { |
| 295 | case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM: |
| 296 | /* power LED */ |
| 297 | sms_set_gpio(coredev, |
| 298 | board->led_power, onoff ? 1 : 0); |
| 299 | break; |
Michael Krufky | dff6574 | 2008-11-22 14:33:00 -0300 | [diff] [blame] | 300 | case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2: |
| 301 | case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD: |
| 302 | /* LNA */ |
Michael Krufky | d54093a | 2008-12-16 02:56:08 -0300 | [diff] [blame] | 303 | if (!onoff) |
| 304 | sms_set_gpio(coredev, board->lna_ctrl, 0); |
Michael Krufky | dff6574 | 2008-11-22 14:33:00 -0300 | [diff] [blame] | 305 | break; |
Michael Krufky | 7a6fbed | 2008-11-22 14:26:37 -0300 | [diff] [blame] | 306 | } |
| 307 | return 0; |
| 308 | } |
Michael Krufky | a0beec8 | 2009-02-26 18:32:36 -0300 | [diff] [blame] | 309 | EXPORT_SYMBOL_GPL(sms_board_power); |
Michael Krufky | 7b29e10 | 2008-11-22 15:32:19 -0300 | [diff] [blame] | 310 | |
| 311 | int sms_board_led_feedback(struct smscore_device_t *coredev, int led) |
| 312 | { |
| 313 | int board_id = smscore_get_board_id(coredev); |
| 314 | struct sms_board *board = sms_get_board(board_id); |
| 315 | |
| 316 | /* dont touch GPIO if LEDs are already set */ |
| 317 | if (smscore_led_state(coredev, -1) == led) |
| 318 | return 0; |
| 319 | |
| 320 | switch (board_id) { |
| 321 | case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM: |
| 322 | sms_set_gpio(coredev, |
| 323 | board->led_lo, (led & SMS_LED_LO) ? 1 : 0); |
| 324 | sms_set_gpio(coredev, |
| 325 | board->led_hi, (led & SMS_LED_HI) ? 1 : 0); |
| 326 | |
| 327 | smscore_led_state(coredev, led); |
| 328 | break; |
| 329 | } |
| 330 | return 0; |
| 331 | } |
Michael Krufky | a0beec8 | 2009-02-26 18:32:36 -0300 | [diff] [blame] | 332 | EXPORT_SYMBOL_GPL(sms_board_led_feedback); |
Michael Krufky | d54093a | 2008-12-16 02:56:08 -0300 | [diff] [blame] | 333 | |
| 334 | int sms_board_lna_control(struct smscore_device_t *coredev, int onoff) |
| 335 | { |
| 336 | int board_id = smscore_get_board_id(coredev); |
| 337 | struct sms_board *board = sms_get_board(board_id); |
| 338 | |
| 339 | sms_debug("%s: LNA %s", __func__, onoff ? "enabled" : "disabled"); |
| 340 | |
| 341 | switch (board_id) { |
| 342 | case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2: |
| 343 | case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD: |
| 344 | sms_set_gpio(coredev, |
| 345 | board->rf_switch, onoff ? 1 : 0); |
| 346 | return sms_set_gpio(coredev, |
| 347 | board->lna_ctrl, onoff ? 1 : 0); |
| 348 | } |
| 349 | return -EINVAL; |
| 350 | } |
Michael Krufky | a0beec8 | 2009-02-26 18:32:36 -0300 | [diff] [blame] | 351 | EXPORT_SYMBOL_GPL(sms_board_lna_control); |
Michael Krufky | 05860f2 | 2008-08-31 17:39:58 -0300 | [diff] [blame] | 352 | |
| 353 | int sms_board_load_modules(int id) |
| 354 | { |
Mauro Carvalho Chehab | 9e915e5 | 2013-03-07 11:35:00 -0300 | [diff] [blame] | 355 | request_module("smsdvb"); |
Michael Krufky | 05860f2 | 2008-08-31 17:39:58 -0300 | [diff] [blame] | 356 | return 0; |
| 357 | } |
Michael Krufky | a0beec8 | 2009-02-26 18:32:36 -0300 | [diff] [blame] | 358 | EXPORT_SYMBOL_GPL(sms_board_load_modules); |