diff options
-rw-r--r-- | arch/arm/mach-s5pv210/Kconfig | 6 | ||||
-rw-r--r-- | arch/arm/mach-s5pv210/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/mach-s5pv210/include/mach/regs-sys.h | 4 | ||||
-rw-r--r-- | arch/arm/mach-s5pv210/setup-usb-phy.c | 90 |
4 files changed, 97 insertions, 4 deletions
diff --git a/arch/arm/mach-s5pv210/Kconfig b/arch/arm/mach-s5pv210/Kconfig index 2cdc42e838b8..82525e3831e9 100644 --- a/arch/arm/mach-s5pv210/Kconfig +++ b/arch/arm/mach-s5pv210/Kconfig | |||
@@ -65,6 +65,11 @@ config S5PV210_SETUP_SPI | |||
65 | help | 65 | help |
66 | Common setup code for SPI GPIO configurations. | 66 | Common setup code for SPI GPIO configurations. |
67 | 67 | ||
68 | config S5PV210_SETUP_USB_PHY | ||
69 | bool | ||
70 | help | ||
71 | Common setup code for USB PHY controller | ||
72 | |||
68 | menu "S5PC110 Machines" | 73 | menu "S5PC110 Machines" |
69 | 74 | ||
70 | config MACH_AQUILA | 75 | config MACH_AQUILA |
@@ -107,6 +112,7 @@ config MACH_GONI | |||
107 | select S5PV210_SETUP_KEYPAD | 112 | select S5PV210_SETUP_KEYPAD |
108 | select S5PV210_SETUP_SDHCI | 113 | select S5PV210_SETUP_SDHCI |
109 | select S5PV210_SETUP_FIMC | 114 | select S5PV210_SETUP_FIMC |
115 | select S5PV210_SETUP_USB_PHY | ||
110 | help | 116 | help |
111 | Machine support for Samsung GONI board | 117 | Machine support for Samsung GONI board |
112 | S5PC110(MCP) is one of package option of S5PV210 | 118 | S5PC110(MCP) is one of package option of S5PV210 |
diff --git a/arch/arm/mach-s5pv210/Makefile b/arch/arm/mach-s5pv210/Makefile index 76a121dd52b4..1c4e41998a10 100644 --- a/arch/arm/mach-s5pv210/Makefile +++ b/arch/arm/mach-s5pv210/Makefile | |||
@@ -39,3 +39,4 @@ obj-$(CONFIG_S5PV210_SETUP_IDE) += setup-ide.o | |||
39 | obj-$(CONFIG_S5PV210_SETUP_KEYPAD) += setup-keypad.o | 39 | obj-$(CONFIG_S5PV210_SETUP_KEYPAD) += setup-keypad.o |
40 | obj-$(CONFIG_S5PV210_SETUP_SDHCI_GPIO) += setup-sdhci-gpio.o | 40 | obj-$(CONFIG_S5PV210_SETUP_SDHCI_GPIO) += setup-sdhci-gpio.o |
41 | obj-$(CONFIG_S5PV210_SETUP_SPI) += setup-spi.o | 41 | obj-$(CONFIG_S5PV210_SETUP_SPI) += setup-spi.o |
42 | obj-$(CONFIG_S5PV210_SETUP_USB_PHY) += setup-usb-phy.o | ||
diff --git a/arch/arm/mach-s5pv210/include/mach/regs-sys.h b/arch/arm/mach-s5pv210/include/mach/regs-sys.h index 26691d39d0f4..cccb1eddaa38 100644 --- a/arch/arm/mach-s5pv210/include/mach/regs-sys.h +++ b/arch/arm/mach-s5pv210/include/mach/regs-sys.h | |||
@@ -13,7 +13,3 @@ | |||
13 | #define S5PV210_USB_PHY_CON (S3C_VA_SYS + 0xE80C) | 13 | #define S5PV210_USB_PHY_CON (S3C_VA_SYS + 0xE80C) |
14 | #define S5PV210_USB_PHY0_EN (1 << 0) | 14 | #define S5PV210_USB_PHY0_EN (1 << 0) |
15 | #define S5PV210_USB_PHY1_EN (1 << 1) | 15 | #define S5PV210_USB_PHY1_EN (1 << 1) |
16 | |||
17 | /* compatibility defines for s3c-hsotg driver */ | ||
18 | #define S3C64XX_OTHERS S5PV210_USB_PHY_CON | ||
19 | #define S3C64XX_OTHERS_USBMASK S5PV210_USB_PHY0_EN | ||
diff --git a/arch/arm/mach-s5pv210/setup-usb-phy.c b/arch/arm/mach-s5pv210/setup-usb-phy.c new file mode 100644 index 000000000000..be39cf4aa91b --- /dev/null +++ b/arch/arm/mach-s5pv210/setup-usb-phy.c | |||
@@ -0,0 +1,90 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2012 Samsung Electronics Co.Ltd | ||
3 | * Author: Joonyoung Shim <jy0922.shim@samsung.com> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License version 2 as | ||
7 | * published by the Free Software Foundationr | ||
8 | */ | ||
9 | |||
10 | #include <linux/clk.h> | ||
11 | #include <linux/delay.h> | ||
12 | #include <linux/err.h> | ||
13 | #include <linux/io.h> | ||
14 | #include <linux/platform_device.h> | ||
15 | #include <mach/map.h> | ||
16 | #include <mach/regs-sys.h> | ||
17 | #include <plat/cpu.h> | ||
18 | #include <plat/regs-usb-hsotg-phy.h> | ||
19 | #include <plat/usb-phy.h> | ||
20 | |||
21 | static int s5pv210_usb_otgphy_init(struct platform_device *pdev) | ||
22 | { | ||
23 | struct clk *xusbxti; | ||
24 | u32 phyclk; | ||
25 | |||
26 | writel(readl(S5PV210_USB_PHY_CON) | S5PV210_USB_PHY0_EN, | ||
27 | S5PV210_USB_PHY_CON); | ||
28 | |||
29 | /* set clock frequency for PLL */ | ||
30 | phyclk = readl(S3C_PHYCLK) & ~S3C_PHYCLK_CLKSEL_MASK; | ||
31 | |||
32 | xusbxti = clk_get(&pdev->dev, "xusbxti"); | ||
33 | if (xusbxti && !IS_ERR(xusbxti)) { | ||
34 | switch (clk_get_rate(xusbxti)) { | ||
35 | case 12 * MHZ: | ||
36 | phyclk |= S3C_PHYCLK_CLKSEL_12M; | ||
37 | break; | ||
38 | case 24 * MHZ: | ||
39 | phyclk |= S3C_PHYCLK_CLKSEL_24M; | ||
40 | break; | ||
41 | default: | ||
42 | case 48 * MHZ: | ||
43 | /* default reference clock */ | ||
44 | break; | ||
45 | } | ||
46 | clk_put(xusbxti); | ||
47 | } | ||
48 | |||
49 | /* TODO: select external clock/oscillator */ | ||
50 | writel(phyclk | S3C_PHYCLK_CLK_FORCE, S3C_PHYCLK); | ||
51 | |||
52 | /* set to normal OTG PHY */ | ||
53 | writel((readl(S3C_PHYPWR) & ~S3C_PHYPWR_NORMAL_MASK), S3C_PHYPWR); | ||
54 | mdelay(1); | ||
55 | |||
56 | /* reset OTG PHY and Link */ | ||
57 | writel(S3C_RSTCON_PHY | S3C_RSTCON_HCLK | S3C_RSTCON_PHYCLK, | ||
58 | S3C_RSTCON); | ||
59 | udelay(20); /* at-least 10uS */ | ||
60 | writel(0, S3C_RSTCON); | ||
61 | |||
62 | return 0; | ||
63 | } | ||
64 | |||
65 | static int s5pv210_usb_otgphy_exit(struct platform_device *pdev) | ||
66 | { | ||
67 | writel((readl(S3C_PHYPWR) | S3C_PHYPWR_ANALOG_POWERDOWN | | ||
68 | S3C_PHYPWR_OTG_DISABLE), S3C_PHYPWR); | ||
69 | |||
70 | writel(readl(S5PV210_USB_PHY_CON) & ~S5PV210_USB_PHY0_EN, | ||
71 | S5PV210_USB_PHY_CON); | ||
72 | |||
73 | return 0; | ||
74 | } | ||
75 | |||
76 | int s5p_usb_phy_init(struct platform_device *pdev, int type) | ||
77 | { | ||
78 | if (type == S5P_USB_PHY_DEVICE) | ||
79 | return s5pv210_usb_otgphy_init(pdev); | ||
80 | |||
81 | return -EINVAL; | ||
82 | } | ||
83 | |||
84 | int s5p_usb_phy_exit(struct platform_device *pdev, int type) | ||
85 | { | ||
86 | if (type == S5P_USB_PHY_DEVICE) | ||
87 | return s5pv210_usb_otgphy_exit(pdev); | ||
88 | |||
89 | return -EINVAL; | ||
90 | } | ||