aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Guo <peter.guo@bayhubtech.com>2014-05-05 06:50:28 -0400
committerChris Ball <chris@printf.net>2014-05-22 08:40:44 -0400
commit706adf6bc31c8e4b2b977e1666a01237e4d10e0d (patch)
treee5eacadd9a5b27e0fbdb0c372e1c1fba85578291
parentee526d515ad12e9fee2d2dbfc7f626c0a5c7f417 (diff)
mmc: sdhci-pci-o2micro: Add SeaBird SeaEagle SD3 support
Add O2Micro/BayHubTech chip 8520 subversion B1 SD3.0 support. Add O2Micro/BayHubTech chip 8620 and 8621 SD3.0 support Enable Led function of 8520 chip. Signed-off-by: Peter Guo <peter.guo@bayhubtech.com> Signed-off-by: Adam Lee <adam.lee@canonical.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Chris Ball <chris@printf.net>
-rw-r--r--drivers/mmc/host/sdhci-pci-o2micro.c78
-rw-r--r--drivers/mmc/host/sdhci-pci-o2micro.h3
2 files changed, 80 insertions, 1 deletions
diff --git a/drivers/mmc/host/sdhci-pci-o2micro.c b/drivers/mmc/host/sdhci-pci-o2micro.c
index f49666bcc52a..5670e381b0cf 100644
--- a/drivers/mmc/host/sdhci-pci-o2micro.c
+++ b/drivers/mmc/host/sdhci-pci-o2micro.c
@@ -21,6 +21,45 @@
21#include "sdhci-pci.h" 21#include "sdhci-pci.h"
22#include "sdhci-pci-o2micro.h" 22#include "sdhci-pci-o2micro.h"
23 23
24static void o2_pci_set_baseclk(struct sdhci_pci_chip *chip, u32 value)
25{
26 u32 scratch_32;
27 pci_read_config_dword(chip->pdev,
28 O2_SD_PLL_SETTING, &scratch_32);
29
30 scratch_32 &= 0x0000FFFF;
31 scratch_32 |= value;
32
33 pci_write_config_dword(chip->pdev,
34 O2_SD_PLL_SETTING, scratch_32);
35}
36
37static void o2_pci_led_enable(struct sdhci_pci_chip *chip)
38{
39 int ret;
40 u32 scratch_32;
41
42 /* Set led of SD host function enable */
43 ret = pci_read_config_dword(chip->pdev,
44 O2_SD_FUNC_REG0, &scratch_32);
45 if (ret)
46 return;
47
48 scratch_32 &= ~O2_SD_FREG0_LEDOFF;
49 pci_write_config_dword(chip->pdev,
50 O2_SD_FUNC_REG0, scratch_32);
51
52 ret = pci_read_config_dword(chip->pdev,
53 O2_SD_TEST_REG, &scratch_32);
54 if (ret)
55 return;
56
57 scratch_32 |= O2_SD_LED_ENABLE;
58 pci_write_config_dword(chip->pdev,
59 O2_SD_TEST_REG, scratch_32);
60
61}
62
24void sdhci_pci_o2_fujin2_pci_init(struct sdhci_pci_chip *chip) 63void sdhci_pci_o2_fujin2_pci_init(struct sdhci_pci_chip *chip)
25{ 64{
26 u32 scratch_32; 65 u32 scratch_32;
@@ -216,6 +255,40 @@ int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
216 scratch &= 0x7f; 255 scratch &= 0x7f;
217 pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); 256 pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch);
218 257
258 /* DevId=8520 subId= 0x11 or 0x12 Type Chip support */
259 if (chip->pdev->device == PCI_DEVICE_ID_O2_FUJIN2) {
260 ret = pci_read_config_dword(chip->pdev,
261 O2_SD_FUNC_REG0,
262 &scratch_32);
263 scratch_32 = ((scratch_32 & 0xFF000000) >> 24);
264
265 /* Check Whether subId is 0x11 or 0x12 */
266 if ((scratch_32 == 0x11) || (scratch_32 == 0x12)) {
267 scratch_32 = 0x2c280000;
268
269 /* Set Base Clock to 208MZ */
270 o2_pci_set_baseclk(chip, scratch_32);
271 ret = pci_read_config_dword(chip->pdev,
272 O2_SD_FUNC_REG4,
273 &scratch_32);
274
275 /* Enable Base Clk setting change */
276 scratch_32 |= O2_SD_FREG4_ENABLE_CLK_SET;
277 pci_write_config_dword(chip->pdev,
278 O2_SD_FUNC_REG4,
279 scratch_32);
280
281 /* Set Tuning Window to 4 */
282 pci_write_config_byte(chip->pdev,
283 O2_SD_TUNING_CTRL, 0x44);
284
285 break;
286 }
287 }
288
289 /* Enable 8520 led function */
290 o2_pci_led_enable(chip);
291
219 /* Set timeout CLK */ 292 /* Set timeout CLK */
220 ret = pci_read_config_dword(chip->pdev, 293 ret = pci_read_config_dword(chip->pdev,
221 O2_SD_CLK_SETTING, &scratch_32); 294 O2_SD_CLK_SETTING, &scratch_32);
@@ -276,7 +349,7 @@ int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
276 pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); 349 pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch);
277 350
278 ret = pci_read_config_dword(chip->pdev, 351 ret = pci_read_config_dword(chip->pdev,
279 O2_SD_FUNC_REG0, &scratch_32); 352 O2_SD_PLL_SETTING, &scratch_32);
280 353
281 if ((scratch_32 & 0xff000000) == 0x01000000) { 354 if ((scratch_32 & 0xff000000) == 0x01000000) {
282 scratch_32 &= 0x0000FFFF; 355 scratch_32 &= 0x0000FFFF;
@@ -299,6 +372,9 @@ int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
299 O2_SD_FUNC_REG4, scratch_32); 372 O2_SD_FUNC_REG4, scratch_32);
300 } 373 }
301 374
375 /* Set Tuning Windows to 5 */
376 pci_write_config_byte(chip->pdev,
377 O2_SD_TUNING_CTRL, 0x55);
302 /* Lock WP */ 378 /* Lock WP */
303 ret = pci_read_config_byte(chip->pdev, 379 ret = pci_read_config_byte(chip->pdev,
304 O2_SD_LOCK_WP, &scratch); 380 O2_SD_LOCK_WP, &scratch);
diff --git a/drivers/mmc/host/sdhci-pci-o2micro.h b/drivers/mmc/host/sdhci-pci-o2micro.h
index dbec4c933488..f7ffc908d9a0 100644
--- a/drivers/mmc/host/sdhci-pci-o2micro.h
+++ b/drivers/mmc/host/sdhci-pci-o2micro.h
@@ -57,6 +57,9 @@
57#define O2_SD_UHS2_L1_CTRL 0x35C 57#define O2_SD_UHS2_L1_CTRL 0x35C
58#define O2_SD_FUNC_REG3 0x3E0 58#define O2_SD_FUNC_REG3 0x3E0
59#define O2_SD_FUNC_REG4 0x3E4 59#define O2_SD_FUNC_REG4 0x3E4
60#define O2_SD_LED_ENABLE BIT(6)
61#define O2_SD_FREG0_LEDOFF BIT(13)
62#define O2_SD_FREG4_ENABLE_CLK_SET BIT(22)
60 63
61#define O2_SD_VENDOR_SETTING 0x110 64#define O2_SD_VENDOR_SETTING 0x110
62#define O2_SD_VENDOR_SETTING2 0x1C8 65#define O2_SD_VENDOR_SETTING2 0x1C8