diff options
| -rw-r--r-- | drivers/gpu/host1x/Makefile | 1 | ||||
| -rw-r--r-- | drivers/gpu/host1x/dev.c | 17 | ||||
| -rw-r--r-- | drivers/gpu/host1x/dev.h | 2 | ||||
| -rw-r--r-- | drivers/gpu/host1x/mipi.c | 272 | ||||
| -rw-r--r-- | include/linux/host1x.h | 6 |
5 files changed, 294 insertions, 4 deletions
diff --git a/drivers/gpu/host1x/Makefile b/drivers/gpu/host1x/Makefile index afa1e9e4e512..de305c2d510e 100644 --- a/drivers/gpu/host1x/Makefile +++ b/drivers/gpu/host1x/Makefile | |||
| @@ -7,6 +7,7 @@ host1x-y = \ | |||
| 7 | channel.o \ | 7 | channel.o \ |
| 8 | job.o \ | 8 | job.o \ |
| 9 | debug.o \ | 9 | debug.o \ |
| 10 | mipi.o \ | ||
| 10 | hw/host1x01.o \ | 11 | hw/host1x01.o \ |
| 11 | hw/host1x02.o | 12 | hw/host1x02.o |
| 12 | 13 | ||
diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c index 80da003d63de..646a333b069a 100644 --- a/drivers/gpu/host1x/dev.c +++ b/drivers/gpu/host1x/dev.c | |||
| @@ -210,17 +210,26 @@ static int __init tegra_host1x_init(void) | |||
| 210 | return err; | 210 | return err; |
| 211 | 211 | ||
| 212 | err = platform_driver_register(&tegra_host1x_driver); | 212 | err = platform_driver_register(&tegra_host1x_driver); |
| 213 | if (err < 0) { | 213 | if (err < 0) |
| 214 | host1x_bus_exit(); | 214 | goto unregister_bus; |
| 215 | return err; | 215 | |
| 216 | } | 216 | err = platform_driver_register(&tegra_mipi_driver); |
| 217 | if (err < 0) | ||
| 218 | goto unregister_host1x; | ||
| 217 | 219 | ||
| 218 | return 0; | 220 | return 0; |
| 221 | |||
| 222 | unregister_host1x: | ||
| 223 | platform_driver_unregister(&tegra_host1x_driver); | ||
| 224 | unregister_bus: | ||
| 225 | host1x_bus_exit(); | ||
| 226 | return err; | ||
| 219 | } | 227 | } |
| 220 | module_init(tegra_host1x_init); | 228 | module_init(tegra_host1x_init); |
| 221 | 229 | ||
| 222 | static void __exit tegra_host1x_exit(void) | 230 | static void __exit tegra_host1x_exit(void) |
| 223 | { | 231 | { |
| 232 | platform_driver_unregister(&tegra_mipi_driver); | ||
| 224 | platform_driver_unregister(&tegra_host1x_driver); | 233 | platform_driver_unregister(&tegra_host1x_driver); |
| 225 | host1x_bus_exit(); | 234 | host1x_bus_exit(); |
| 226 | } | 235 | } |
diff --git a/drivers/gpu/host1x/dev.h b/drivers/gpu/host1x/dev.h index a61a976e7a42..0b6e8e9629c5 100644 --- a/drivers/gpu/host1x/dev.h +++ b/drivers/gpu/host1x/dev.h | |||
| @@ -306,4 +306,6 @@ static inline void host1x_hw_show_mlocks(struct host1x *host, struct output *o) | |||
| 306 | host->debug_op->show_mlocks(host, o); | 306 | host->debug_op->show_mlocks(host, o); |
| 307 | } | 307 | } |
| 308 | 308 | ||
| 309 | extern struct platform_driver tegra_mipi_driver; | ||
| 310 | |||
| 309 | #endif | 311 | #endif |
diff --git a/drivers/gpu/host1x/mipi.c b/drivers/gpu/host1x/mipi.c new file mode 100644 index 000000000000..518b98dd3087 --- /dev/null +++ b/drivers/gpu/host1x/mipi.c | |||
| @@ -0,0 +1,272 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2013 NVIDIA Corporation | ||
| 3 | * | ||
| 4 | * Permission to use, copy, modify, distribute, and sell this software and its | ||
| 5 | * documentation for any purpose is hereby granted without fee, provided that | ||
| 6 | * the above copyright notice appear in all copies and that both that copyright | ||
| 7 | * notice and this permission notice appear in supporting documentation, and | ||
| 8 | * that the name of the copyright holders not be used in advertising or | ||
| 9 | * publicity pertaining to distribution of the software without specific, | ||
| 10 | * written prior permission. The copyright holders make no representations | ||
| 11 | * about the suitability of this software for any purpose. It is provided "as | ||
| 12 | * is" without express or implied warranty. | ||
| 13 | * | ||
| 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | ||
| 15 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO | ||
| 16 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR | ||
| 17 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, | ||
| 18 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER | ||
| 19 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE | ||
| 20 | * OF THIS SOFTWARE. | ||
| 21 | */ | ||
| 22 | |||
| 23 | #include <linux/clk.h> | ||
| 24 | #include <linux/delay.h> | ||
| 25 | #include <linux/io.h> | ||
| 26 | #include <linux/of_platform.h> | ||
| 27 | #include <linux/platform_device.h> | ||
| 28 | #include <linux/slab.h> | ||
| 29 | |||
| 30 | #define MIPI_CAL_CTRL 0x00 | ||
| 31 | #define MIPI_CAL_CTRL_START (1 << 0) | ||
| 32 | |||
| 33 | #define MIPI_CAL_AUTOCAL_CTRL 0x01 | ||
| 34 | |||
| 35 | #define MIPI_CAL_STATUS 0x02 | ||
| 36 | #define MIPI_CAL_STATUS_DONE (1 << 16) | ||
| 37 | #define MIPI_CAL_STATUS_ACTIVE (1 << 0) | ||
| 38 | |||
| 39 | #define MIPI_CAL_CONFIG_CSIA 0x05 | ||
| 40 | #define MIPI_CAL_CONFIG_CSIB 0x06 | ||
| 41 | #define MIPI_CAL_CONFIG_CSIC 0x07 | ||
| 42 | #define MIPI_CAL_CONFIG_CSID 0x08 | ||
| 43 | #define MIPI_CAL_CONFIG_CSIE 0x09 | ||
| 44 | #define MIPI_CAL_CONFIG_DSIA 0x0e | ||
| 45 | #define MIPI_CAL_CONFIG_DSIB 0x0f | ||
| 46 | #define MIPI_CAL_CONFIG_DSIC 0x10 | ||
| 47 | #define MIPI_CAL_CONFIG_DSID 0x11 | ||
| 48 | |||
| 49 | #define MIPI_CAL_CONFIG_SELECT (1 << 21) | ||
| 50 | #define MIPI_CAL_CONFIG_HSPDOS(x) (((x) & 0x1f) << 16) | ||
| 51 | #define MIPI_CAL_CONFIG_HSPUOS(x) (((x) & 0x1f) << 8) | ||
| 52 | #define MIPI_CAL_CONFIG_TERMOS(x) (((x) & 0x1f) << 0) | ||
| 53 | |||
| 54 | #define MIPI_CAL_BIAS_PAD_CFG0 0x16 | ||
| 55 | #define MIPI_CAL_BIAS_PAD_PDVCLAMP (1 << 1) | ||
| 56 | #define MIPI_CAL_BIAS_PAD_E_VCLAMP_REF (1 << 0) | ||
| 57 | |||
| 58 | #define MIPI_CAL_BIAS_PAD_CFG1 0x17 | ||
| 59 | |||
| 60 | #define MIPI_CAL_BIAS_PAD_CFG2 0x18 | ||
| 61 | #define MIPI_CAL_BIAS_PAD_PDVREG (1 << 1) | ||
| 62 | |||
| 63 | static const struct module { | ||
| 64 | unsigned long reg; | ||
| 65 | } modules[] = { | ||
| 66 | { .reg = MIPI_CAL_CONFIG_CSIA }, | ||
| 67 | { .reg = MIPI_CAL_CONFIG_CSIB }, | ||
| 68 | { .reg = MIPI_CAL_CONFIG_CSIC }, | ||
| 69 | { .reg = MIPI_CAL_CONFIG_CSID }, | ||
| 70 | { .reg = MIPI_CAL_CONFIG_CSIE }, | ||
| 71 | { .reg = MIPI_CAL_CONFIG_DSIA }, | ||
| 72 | { .reg = MIPI_CAL_CONFIG_DSIB }, | ||
| 73 | { .reg = MIPI_CAL_CONFIG_DSIC }, | ||
| 74 | { .reg = MIPI_CAL_CONFIG_DSID }, | ||
| 75 | }; | ||
| 76 | |||
| 77 | struct tegra_mipi { | ||
| 78 | void __iomem *regs; | ||
| 79 | struct mutex lock; | ||
| 80 | struct clk *clk; | ||
| 81 | }; | ||
| 82 | |||
| 83 | struct tegra_mipi_device { | ||
| 84 | struct platform_device *pdev; | ||
| 85 | struct tegra_mipi *mipi; | ||
| 86 | struct device *device; | ||
| 87 | unsigned long pads; | ||
| 88 | }; | ||
| 89 | |||
| 90 | static inline unsigned long tegra_mipi_readl(struct tegra_mipi *mipi, | ||
| 91 | unsigned long reg) | ||
| 92 | { | ||
| 93 | return readl(mipi->regs + (reg << 2)); | ||
| 94 | } | ||
| 95 | |||
| 96 | static inline void tegra_mipi_writel(struct tegra_mipi *mipi, | ||
| 97 | unsigned long value, unsigned long reg) | ||
| 98 | { | ||
| 99 | writel(value, mipi->regs + (reg << 2)); | ||
| 100 | } | ||
| 101 | |||
| 102 | struct tegra_mipi_device *tegra_mipi_request(struct device *device) | ||
| 103 | { | ||
| 104 | struct device_node *np = device->of_node; | ||
| 105 | struct tegra_mipi_device *dev; | ||
| 106 | struct of_phandle_args args; | ||
| 107 | int err; | ||
| 108 | |||
| 109 | err = of_parse_phandle_with_args(np, "nvidia,mipi-calibrate", | ||
| 110 | "#nvidia,mipi-calibrate-cells", 0, | ||
| 111 | &args); | ||
| 112 | if (err < 0) | ||
| 113 | return ERR_PTR(err); | ||
| 114 | |||
| 115 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | ||
| 116 | if (!dev) { | ||
| 117 | of_node_put(args.np); | ||
| 118 | err = -ENOMEM; | ||
| 119 | goto out; | ||
| 120 | } | ||
| 121 | |||
| 122 | dev->pdev = of_find_device_by_node(args.np); | ||
| 123 | if (!dev->pdev) { | ||
| 124 | of_node_put(args.np); | ||
| 125 | err = -ENODEV; | ||
| 126 | goto free; | ||
| 127 | } | ||
| 128 | |||
| 129 | of_node_put(args.np); | ||
| 130 | |||
| 131 | dev->mipi = platform_get_drvdata(dev->pdev); | ||
| 132 | if (!dev->mipi) { | ||
| 133 | err = -EPROBE_DEFER; | ||
| 134 | goto pdev_put; | ||
| 135 | } | ||
| 136 | |||
| 137 | dev->pads = args.args[0]; | ||
| 138 | dev->device = device; | ||
