diff options
| author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2017-08-04 18:43:53 -0400 |
|---|---|---|
| committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2017-08-15 08:18:25 -0400 |
| commit | 9e1305d0d1fd8f1b47203eac4fb3eb05d64a5ffd (patch) | |
| tree | bcd37709966903e1afbb3923543c2e93a3807ba2 /drivers/gpu/drm/omapdrm | |
| parent | 742e693b066613161442c2aec5b1772c7fa1da10 (diff) | |
drm: omapdrm: dsi: Handle pin muxing internally
Don't rely on callback functions provided by the platform, but access
the syscon internally to mux the DSI pins.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'drivers/gpu/drm/omapdrm')
| -rw-r--r-- | drivers/gpu/drm/omapdrm/dss/core.c | 20 | ||||
| -rw-r--r-- | drivers/gpu/drm/omapdrm/dss/dsi.c | 82 | ||||
| -rw-r--r-- | drivers/gpu/drm/omapdrm/dss/dss.h | 2 |
3 files changed, 79 insertions, 25 deletions
diff --git a/drivers/gpu/drm/omapdrm/dss/core.c b/drivers/gpu/drm/omapdrm/dss/core.c index bdce4bfdf6e0..a6baa0a0a973 100644 --- a/drivers/gpu/drm/omapdrm/dss/core.c +++ b/drivers/gpu/drm/omapdrm/dss/core.c | |||
| @@ -50,26 +50,6 @@ enum omapdss_version omapdss_get_version(void) | |||
| 50 | } | 50 | } |
| 51 | EXPORT_SYMBOL(omapdss_get_version); | 51 | EXPORT_SYMBOL(omapdss_get_version); |
| 52 | 52 | ||
| 53 | int dss_dsi_enable_pads(int dsi_id, unsigned lane_mask) | ||
| 54 | { | ||
| 55 | struct omap_dss_board_info *board_data = core.pdev->dev.platform_data; | ||
| 56 | |||
| 57 | if (!board_data->dsi_enable_pads) | ||
| 58 | return -ENOENT; | ||
| 59 | |||
| 60 | return board_data->dsi_enable_pads(dsi_id, lane_mask); | ||
| 61 | } | ||
| 62 | |||
| 63 | void dss_dsi_disable_pads(int dsi_id, unsigned lane_mask) | ||
| 64 | { | ||
| 65 | struct omap_dss_board_info *board_data = core.pdev->dev.platform_data; | ||
| 66 | |||
| 67 | if (!board_data->dsi_disable_pads) | ||
| 68 | return; | ||
| 69 | |||
| 70 | return board_data->dsi_disable_pads(dsi_id, lane_mask); | ||
| 71 | } | ||
| 72 | |||
| 73 | int dss_set_min_bus_tput(struct device *dev, unsigned long tput) | 53 | int dss_set_min_bus_tput(struct device *dev, unsigned long tput) |
| 74 | { | 54 | { |
| 75 | struct omap_dss_board_info *pdata = core.pdev->dev.platform_data; | 55 | struct omap_dss_board_info *pdata = core.pdev->dev.platform_data; |
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c index 59e099f9e49d..3d98e9ce9a43 100644 --- a/drivers/gpu/drm/omapdrm/dss/dsi.c +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c | |||
| @@ -20,6 +20,8 @@ | |||
| 20 | #define DSS_SUBSYS_NAME "DSI" | 20 | #define DSS_SUBSYS_NAME "DSI" |
| 21 | 21 | ||
| 22 | #include <linux/kernel.h> | 22 | #include <linux/kernel.h> |
| 23 | #include <linux/mfd/syscon.h> | ||
| 24 | #include <linux/regmap.h> | ||
| 23 | #include <linux/io.h> | 25 | #include <linux/io.h> |
| 24 | #include <linux/clk.h> | 26 | #include <linux/clk.h> |
| 25 | #include <linux/device.h> | 27 | #include <linux/device.h> |
| @@ -330,6 +332,7 @@ struct dsi_data { | |||
| 330 | bool is_enabled; | 332 | bool is_enabled; |
| 331 | 333 | ||
| 332 | struct clk *dss_clk; | 334 | struct clk *dss_clk; |
| 335 | struct regmap *syscon; | ||
| 333 | 336 | ||
| 334 | struct dispc_clock_info user_dispc_cinfo; | 337 | struct dispc_clock_info user_dispc_cinfo; |
| 335 | struct dss_pll_clock_info user_dsi_cinfo; | 338 | struct dss_pll_clock_info user_dsi_cinfo; |
| @@ -2073,6 +2076,64 @@ static unsigned dsi_get_lane_mask(struct platform_device *dsidev) | |||
| 2073 | return mask; | 2076 | return mask; |
| 2074 | } | 2077 | } |
| 2075 | 2078 | ||
| 2079 | /* OMAP4 CONTROL_DSIPHY */ | ||
| 2080 | #define OMAP4_DSIPHY_SYSCON_OFFSET 0x78 | ||
| 2081 | |||
| 2082 | #define OMAP4_DSI2_LANEENABLE_SHIFT 29 | ||
| 2083 | #define OMAP4_DSI2_LANEENABLE_MASK (0x7 << 29) | ||
| 2084 | #define OMAP4_DSI1_LANEENABLE_SHIFT 24 | ||
| 2085 | #define OMAP4_DSI1_LANEENABLE_MASK (0x1f << 24) | ||
| 2086 | #define OMAP4_DSI1_PIPD_SHIFT 19 | ||
| 2087 | #define OMAP4_DSI1_PIPD_MASK (0x1f << 19) | ||
| 2088 | #define OMAP4_DSI2_PIPD_SHIFT 14 | ||
| 2089 | #define OMAP4_DSI2_PIPD_MASK (0x1f << 14) | ||
| 2090 | |||
| 2091 | static int dsi_omap4_mux_pads(struct dsi_data *dsi, unsigned int lanes) | ||
| 2092 | { | ||
| 2093 | u32 enable_mask, enable_shift; | ||
| 2094 | u32 pipd_mask, pipd_shift; | ||
| 2095 | u32 reg; | ||
| 2096 | |||
| 2097 | if (!dsi->syscon) | ||
| 2098 | return 0; | ||
| 2099 | |||
| 2100 | if (dsi->module_id == 0) { | ||
| 2101 | enable_mask = OMAP4_DSI1_LANEENABLE_MASK; | ||
| 2102 | enable_shift = OMAP4_DSI1_LANEENABLE_SHIFT; | ||
| 2103 | pipd_mask = OMAP4_DSI1_PIPD_MASK; | ||
| 2104 | pipd_shift = OMAP4_DSI1_PIPD_SHIFT; | ||
| 2105 | } else if (dsi->module_id == 1) { | ||
| 2106 | enable_mask = OMAP4_DSI2_LANEENABLE_MASK; | ||
| 2107 | enable_shift = OMAP4_DSI2_LANEENABLE_SHIFT; | ||
| 2108 | pipd_mask = OMAP4_DSI2_PIPD_MASK; | ||
| 2109 | pipd_shift = OMAP4_DSI2_PIPD_SHIFT; | ||
| 2110 | } else { | ||
| 2111 | return -ENODEV; | ||
| 2112 | } | ||
| 2113 | |||
| 2114 | regmap_read(dsi->syscon, OMAP4_DSIPHY_SYSCON_OFFSET, ®); | ||
| 2115 | |||
| 2116 | reg &= ~enable_mask; | ||
| 2117 | reg &= ~pipd_mask; | ||
| 2118 | |||
| 2119 | reg |= (lanes << enable_shift) & enable_mask; | ||
| 2120 | reg |= (lanes << pipd_shift) & pipd_mask; | ||
| 2121 | |||
| 2122 | regmap_write(dsi->syscon, OMAP4_DSIPHY_SYSCON_OFFSET, reg); | ||
| 2123 | |||
| 2124 | return 0; | ||
| 2125 | } | ||
| 2126 | |||
| 2127 | static int dsi_enable_pads(struct dsi_data *dsi, unsigned int lane_mask) | ||
| 2128 | { | ||
| 2129 | return dsi_omap4_mux_pads(dsi, lane_mask); | ||
| 2130 | } | ||
| 2131 | |||
| 2132 | static void dsi_disable_pads(struct dsi_data *dsi) | ||
| 2133 | { | ||
| 2134 | dsi_omap4_mux_pads(dsi, 0); | ||
| 2135 | } | ||
| 2136 | |||
| 2076 | static int dsi_cio_init(struct platform_device *dsidev) | 2137 | static int dsi_cio_init(struct platform_device *dsidev) |
| 2077 | { | 2138 | { |
| 2078 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); | 2139 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| @@ -2081,7 +2142,7 @@ static int dsi_cio_init(struct platform_device *dsidev) | |||
| 2081 | 2142 | ||
| 2082 | DSSDBG("DSI CIO init starts"); | 2143 | DSSDBG("DSI CIO init starts"); |
| 2083 | 2144 | ||
| 2084 | r = dss_dsi_enable_pads(dsi->module_id, dsi_get_lane_mask(dsidev)); | 2145 | r = dsi_enable_pads(dsi, dsi_get_lane_mask(dsidev)); |
| 2085 | if (r) | 2146 | if (r) |
| 2086 | return r; | 2147 | return r; |
| 2087 | 2148 | ||
| @@ -2191,7 +2252,7 @@ err_cio_pwr: | |||
| 2191 | dsi_cio_disable_lane_override(dsidev); | 2252 | dsi_cio_disable_lane_override(dsidev); |
| 2192 | err_scp_clk_dom: | 2253 | err_scp_clk_dom: |
| 2193 | dsi_disable_scp_clk(dsidev); | 2254 | dsi_disable_scp_clk(dsidev); |
| 2194 | dss_dsi_disable_pads(dsi->module_id, dsi_get_lane_mask(dsidev)); | 2255 | dsi_disable_pads(dsi); |
| 2195 | return r; | 2256 | return r; |
| 2196 | } | 2257 | } |
| 2197 | 2258 | ||
| @@ -2204,7 +2265,7 @@ static void dsi_cio_uninit(struct platform_device *dsidev) | |||
| 2204 | 2265 | ||
| 2205 | dsi_cio_power(dsidev, DSI_COMPLEXIO_POWER_OFF); | 2266 | dsi_cio_power(dsidev, DSI_COMPLEXIO_POWER_OFF); |
| 2206 | dsi_disable_scp_clk(dsidev); | 2267 | dsi_disable_scp_clk(dsidev); |
| 2207 | dss_dsi_disable_pads(dsi->module_id, dsi_get_lane_mask(dsidev)); | 2268 | dsi_disable_pads(dsi); |
| 2208 | } | 2269 | } |
| 2209 | 2270 | ||
| 2210 | static void dsi_config_tx_fifo(struct platform_device *dsidev, | 2271 | static void dsi_config_tx_fifo(struct platform_device *dsidev, |
| @@ -5332,6 +5393,21 @@ static int dsi_bind(struct device *dev, struct device *master, void *data) | |||
| 5332 | 5393 | ||
| 5333 | dsi->module_id = d->id; | 5394 | dsi->module_id = d->id; |
| 5334 | 5395 | ||
| 5396 | if (dsi->data->model == DSI_MODEL_OMAP4) { | ||
| 5397 | struct device_node *np; | ||
| 5398 | |||
| 5399 | /* | ||
| 5400 | * The OMAP4 display DT bindings don't reference the padconf | ||
| 5401 | * syscon. Our only option to retrieve it is to find it by name. | ||
| 5402 | */ | ||
| 5403 | np = of_find_node_by_name(NULL, "omap4_padconf_global"); | ||
| 5404 | if (!np) | ||
| 5405 | return -ENODEV; | ||
| 5406 | |||
| 5407 | dsi->syscon = syscon_node_to_regmap(np); | ||
| 5408 | of_node_put(np); | ||
| 5409 | } | ||
| 5410 | |||
| 5335 | /* DSI VCs initialization */ | 5411 | /* DSI VCs initialization */ |
| 5336 | for (i = 0; i < ARRAY_SIZE(dsi->vc); i++) { | 5412 | for (i = 0; i < ARRAY_SIZE(dsi->vc); i++) { |
| 5337 | dsi->vc[i].source = DSI_VC_SOURCE_L4; | 5413 | dsi->vc[i].source = DSI_VC_SOURCE_L4; |
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h index 8dbf35f3ab23..668ff93512db 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.h +++ b/drivers/gpu/drm/omapdrm/dss/dss.h | |||
| @@ -219,8 +219,6 @@ struct seq_file; | |||
| 219 | struct platform_device; | 219 | struct platform_device; |
| 220 | 220 | ||
| 221 | /* core */ | 221 | /* core */ |
| 222 | int dss_dsi_enable_pads(int dsi_id, unsigned lane_mask); | ||
| 223 | void dss_dsi_disable_pads(int dsi_id, unsigned lane_mask); | ||
| 224 | int dss_set_min_bus_tput(struct device *dev, unsigned long tput); | 222 | int dss_set_min_bus_tput(struct device *dev, unsigned long tput); |
| 225 | int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *)); | 223 | int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *)); |
| 226 | 224 | ||
