diff options
author | Archit Taneja <architt@codeaurora.org> | 2016-02-12 04:18:31 -0500 |
---|---|---|
committer | Thierry Reding <treding@nvidia.com> | 2016-03-02 11:00:18 -0500 |
commit | c63ae8a9686bb8c87154a31dc5ebadbda778a8e5 (patch) | |
tree | c417cd6f3c7fab96c46e01bf5091a918611b458a /drivers | |
parent | fc903ebd50d0396b5de1ff614a009c2ddcb3222c (diff) |
drm/dsi: Use mipi_dsi_device_register_full() for DSI device creation
Use mipi_dsi_device_register_full() for device creation. This takes in
a struct mipi_dsi_device_info as a template to populate the DSI device
information.
The reason to introduce this is to have a way to create DSI devices not
available via DT. Drivers that want to create a DSI device can populate
a struct mipi_dsi_device_info and call this function. For DSI devices
available via DT, of_mipi_dsi_device_add() is used as before, but this
now calls mipi_dsi_device_register_full() internally.
Signed-off-by: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/drm_mipi_dsi.c | 64 |
1 files changed, 47 insertions, 17 deletions
diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c index 4f2a70471e05..5d7243da2323 100644 --- a/drivers/gpu/drm/drm_mipi_dsi.c +++ b/drivers/gpu/drm/drm_mipi_dsi.c | |||
@@ -133,8 +133,8 @@ static int mipi_dsi_device_add(struct mipi_dsi_device *dsi) | |||
133 | static struct mipi_dsi_device * | 133 | static struct mipi_dsi_device * |
134 | of_mipi_dsi_device_add(struct mipi_dsi_host *host, struct device_node *node) | 134 | of_mipi_dsi_device_add(struct mipi_dsi_host *host, struct device_node *node) |
135 | { | 135 | { |
136 | struct mipi_dsi_device *dsi; | ||
137 | struct device *dev = host->dev; | 136 | struct device *dev = host->dev; |
137 | struct mipi_dsi_device_info info = { }; | ||
138 | int ret; | 138 | int ret; |
139 | u32 reg; | 139 | u32 reg; |
140 | 140 | ||
@@ -145,39 +145,69 @@ of_mipi_dsi_device_add(struct mipi_dsi_host *host, struct device_node *node) | |||
145 | return ERR_PTR(-EINVAL); | 145 | return ERR_PTR(-EINVAL); |
146 | } | 146 | } |
147 | 147 | ||
148 | if (reg > 3) { | 148 | info.channel = reg; |
149 | dev_err(dev, "device node %s has invalid reg property: %u\n", | 149 | info.node = of_node_get(node); |
150 | node->full_name, reg); | 150 | |
151 | return mipi_dsi_device_register_full(host, &info); | ||
152 | } | ||
153 | #else | ||
154 | static struct mipi_dsi_device * | ||
155 | of_mipi_dsi_device_add(struct mipi_dsi_host *host, struct device_node *node) | ||
156 | { | ||
157 | return ERR_PTR(-ENODEV); | ||
158 | } | ||
159 | #endif | ||
160 | |||
161 | /** | ||
162 | * mipi_dsi_device_register_full - create a MIPI DSI device | ||
163 | * @host: DSI host to which this device is connected | ||
164 | * @info: pointer to template containing DSI device information | ||
165 | * | ||
166 | * Create a MIPI DSI device by using the device information provided by | ||
167 | * mipi_dsi_device_info template | ||
168 | * | ||
169 | * Returns: | ||
170 | * A pointer to the newly created MIPI DSI device, or, a pointer encoded | ||
171 | * with an error | ||
172 | */ | ||
173 | struct mipi_dsi_device * | ||
174 | mipi_dsi_device_register_full(struct mipi_dsi_host *host, | ||
175 | const struct mipi_dsi_device_info *info) | ||
176 | { | ||
177 | struct mipi_dsi_device *dsi; | ||
178 | struct device *dev = host->dev; | ||
179 | int ret; | ||
180 | |||
181 | if (!info) { | ||
182 | dev_err(dev, "invalid mipi_dsi_device_info pointer\n"); | ||
183 | return ERR_PTR(-EINVAL); | ||
184 | } | ||
185 | |||
186 | if (info->channel > 3) { | ||
187 | dev_err(dev, "invalid virtual channel: %u\n", info->channel); | ||
151 | return ERR_PTR(-EINVAL); | 188 | return ERR_PTR(-EINVAL); |
152 | } | 189 | } |
153 | 190 | ||
154 | dsi = mipi_dsi_device_alloc(host); | 191 | dsi = mipi_dsi_device_alloc(host); |
155 | if (IS_ERR(dsi)) { | 192 | if (IS_ERR(dsi)) { |
156 | dev_err(dev, "failed to allocate DSI device %s: %ld\n", | 193 | dev_err(dev, "failed to allocate DSI device %ld\n", |
157 | node->full_name, PTR_ERR(dsi)); | 194 | PTR_ERR(dsi)); |
158 | return dsi; | 195 | return dsi; |
159 | } | 196 | } |
160 | 197 | ||
161 | dsi->dev.of_node = of_node_get(node); | 198 | dsi->dev.of_node = info->node; |
162 | dsi->channel = reg; | 199 | dsi->channel = info->channel; |
163 | 200 | ||
164 | ret = mipi_dsi_device_add(dsi); | 201 | ret = mipi_dsi_device_add(dsi); |
165 | if (ret) { | 202 | if (ret) { |
166 | dev_err(dev, "failed to add DSI device %s: %d\n", | 203 | dev_err(dev, "failed to add DSI device %d\n", ret); |
167 | node->full_name, ret); | ||
168 | kfree(dsi); | 204 | kfree(dsi); |
169 | return ERR_PTR(ret); | 205 | return ERR_PTR(ret); |
170 | } | 206 | } |
171 | 207 | ||
172 | return dsi; | 208 | return dsi; |
173 | } | 209 | } |
174 | #else | 210 | EXPORT_SYMBOL(mipi_dsi_device_register_full); |
175 | static struct mipi_dsi_device * | ||
176 | of_mipi_dsi_device_add(struct mipi_dsi_host *host, struct device_node *node) | ||
177 | { | ||
178 | return ERR_PTR(-ENODEV); | ||
179 | } | ||
180 | #endif | ||
181 | 211 | ||
182 | int mipi_dsi_host_register(struct mipi_dsi_host *host) | 212 | int mipi_dsi_host_register(struct mipi_dsi_host *host) |
183 | { | 213 | { |