Stefan Bosch | b7719a7 | 2020-07-10 19:07:34 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright (C) 2016 Nexell Co., Ltd. |
| 4 | * |
| 5 | * Author: junghyun, kim <jhkim@nexell.co.kr> |
| 6 | */ |
| 7 | |
| 8 | #include <linux/types.h> |
| 9 | #include <linux/io.h> |
| 10 | |
| 11 | #include "s5pxx18_soc_disptop.h" |
| 12 | #include "s5pxx18_soc_lvds.h" |
| 13 | |
| 14 | #ifndef pow |
| 15 | static inline unsigned int pow(int a, int b) |
| 16 | { |
| 17 | if (b == 0) |
| 18 | return 1; |
| 19 | else |
| 20 | return a * pow(a, b - 1); |
| 21 | } |
| 22 | #endif |
| 23 | |
| 24 | static struct nx_lvds_register_set *__g_pregister[NUMBER_OF_LVDS_MODULE]; |
| 25 | |
| 26 | int nx_lvds_initialize(void) |
| 27 | { |
| 28 | static int binit; |
| 29 | u32 i; |
| 30 | |
| 31 | if (binit == 0) { |
| 32 | for (i = 0; i < NUMBER_OF_LVDS_MODULE; i++) |
| 33 | __g_pregister[i] = NULL; |
| 34 | binit = 1; |
| 35 | } |
| 36 | |
| 37 | return 1; |
| 38 | } |
| 39 | |
| 40 | u32 nx_lvds_get_number_of_module(void) |
| 41 | { |
| 42 | return NUMBER_OF_LVDS_MODULE; |
| 43 | } |
| 44 | |
| 45 | u32 nx_lvds_get_size_of_register_set(void) |
| 46 | { |
| 47 | return sizeof(struct nx_lvds_register_set); |
| 48 | } |
| 49 | |
| 50 | void nx_lvds_set_base_address(u32 module_index, void *base_address) |
| 51 | { |
| 52 | __g_pregister[module_index] = |
| 53 | (struct nx_lvds_register_set *)base_address; |
| 54 | } |
| 55 | |
| 56 | void *nx_lvds_get_base_address(u32 module_index) |
| 57 | { |
| 58 | return (void *)__g_pregister[module_index]; |
| 59 | } |
| 60 | |
| 61 | u32 nx_lvds_get_physical_address(u32 module_index) |
| 62 | { |
| 63 | const u32 physical_addr[] = PHY_BASEADDR_LVDS_LIST; |
| 64 | |
| 65 | return physical_addr[module_index]; |
| 66 | } |
| 67 | |
| 68 | int nx_lvds_open_module(u32 module_index) |
| 69 | { |
| 70 | return true; |
| 71 | } |
| 72 | |
| 73 | int nx_lvds_close_module(u32 module_index) |
| 74 | { |
| 75 | return true; |
| 76 | } |
| 77 | |
| 78 | int nx_lvds_check_busy(u32 module_index) |
| 79 | { |
| 80 | return false; |
| 81 | } |
| 82 | |
| 83 | void nx_lvds_set_lvdsctrl0(u32 module_index, u32 regvalue) |
| 84 | { |
| 85 | register struct nx_lvds_register_set *pregister; |
| 86 | |
| 87 | pregister = __g_pregister[module_index]; |
| 88 | writel(regvalue, &pregister->lvdsctrl0); |
| 89 | } |
| 90 | |
| 91 | void nx_lvds_set_lvdsctrl1(u32 module_index, u32 regvalue) |
| 92 | { |
| 93 | register struct nx_lvds_register_set *pregister; |
| 94 | |
| 95 | pregister = __g_pregister[module_index]; |
| 96 | writel(regvalue, &pregister->lvdsctrl1); |
| 97 | } |
| 98 | |
| 99 | void nx_lvds_set_lvdsctrl2(u32 module_index, u32 regvalue) |
| 100 | { |
| 101 | register struct nx_lvds_register_set *pregister; |
| 102 | |
| 103 | pregister = __g_pregister[module_index]; |
| 104 | writel(regvalue, &pregister->lvdsctrl2); |
| 105 | } |
| 106 | |
| 107 | void nx_lvds_set_lvdsctrl3(u32 module_index, u32 regvalue) |
| 108 | { |
| 109 | register struct nx_lvds_register_set *pregister; |
| 110 | |
| 111 | pregister = __g_pregister[module_index]; |
| 112 | writel(regvalue, &pregister->lvdsctrl3); |
| 113 | } |
| 114 | |
| 115 | void nx_lvds_set_lvdsctrl4(u32 module_index, u32 regvalue) |
| 116 | { |
| 117 | register struct nx_lvds_register_set *pregister; |
| 118 | |
| 119 | pregister = __g_pregister[module_index]; |
| 120 | writel(regvalue, &pregister->lvdsctrl4); |
| 121 | } |
| 122 | |
| 123 | void nx_lvds_set_lvdstmode0(u32 module_index, u32 regvalue) |
| 124 | { |
| 125 | register struct nx_lvds_register_set *pregister; |
| 126 | |
| 127 | pregister = __g_pregister[module_index]; |
| 128 | writel(regvalue, &pregister->lvdstmode0); |
| 129 | } |
| 130 | |
| 131 | void nx_lvds_set_lvdsloc0(u32 module_index, u32 regvalue) |
| 132 | { |
| 133 | register struct nx_lvds_register_set *pregister; |
| 134 | |
| 135 | pregister = __g_pregister[module_index]; |
| 136 | writel(regvalue, &pregister->lvdsloc0); |
| 137 | } |
| 138 | |
| 139 | void nx_lvds_set_lvdsloc1(u32 module_index, u32 regvalue) |
| 140 | { |
| 141 | register struct nx_lvds_register_set *pregister; |
| 142 | |
| 143 | pregister = __g_pregister[module_index]; |
| 144 | writel(regvalue, &pregister->lvdsloc1); |
| 145 | } |
| 146 | |
| 147 | void nx_lvds_set_lvdsloc2(u32 module_index, u32 regvalue) |
| 148 | { |
| 149 | register struct nx_lvds_register_set *pregister; |
| 150 | |
| 151 | pregister = __g_pregister[module_index]; |
| 152 | writel(regvalue, &pregister->lvdsloc2); |
| 153 | } |
| 154 | |
| 155 | void nx_lvds_set_lvdsloc3(u32 module_index, u32 regvalue) |
| 156 | { |
| 157 | register struct nx_lvds_register_set *pregister; |
| 158 | |
| 159 | pregister = __g_pregister[module_index]; |
| 160 | writel(regvalue, &pregister->lvdsloc3); |
| 161 | } |
| 162 | |
| 163 | void nx_lvds_set_lvdsloc4(u32 module_index, u32 regvalue) |
| 164 | { |
| 165 | register struct nx_lvds_register_set *pregister; |
| 166 | |
| 167 | pregister = __g_pregister[module_index]; |
| 168 | writel(regvalue, &pregister->lvdsloc4); |
| 169 | } |
| 170 | |
| 171 | void nx_lvds_set_lvdsloc5(u32 module_index, u32 regvalue) |
| 172 | { |
| 173 | register struct nx_lvds_register_set *pregister; |
| 174 | |
| 175 | pregister = __g_pregister[module_index]; |
| 176 | writel(regvalue, &pregister->lvdsloc5); |
| 177 | } |
| 178 | |
| 179 | void nx_lvds_set_lvdsloc6(u32 module_index, u32 regvalue) |
| 180 | { |
| 181 | register struct nx_lvds_register_set *pregister; |
| 182 | |
| 183 | pregister = __g_pregister[module_index]; |
| 184 | writel(regvalue, &pregister->lvdsloc6); |
| 185 | } |
| 186 | |
| 187 | void nx_lvds_set_lvdslocmask0(u32 module_index, u32 regvalue) |
| 188 | { |
| 189 | register struct nx_lvds_register_set *pregister; |
| 190 | |
| 191 | pregister = __g_pregister[module_index]; |
| 192 | writel(regvalue, &pregister->lvdslocmask0); |
| 193 | } |
| 194 | |
| 195 | void nx_lvds_set_lvdslocmask1(u32 module_index, u32 regvalue) |
| 196 | { |
| 197 | register struct nx_lvds_register_set *pregister; |
| 198 | |
| 199 | pregister = __g_pregister[module_index]; |
| 200 | writel(regvalue, &pregister->lvdslocmask1); |
| 201 | } |
| 202 | |
| 203 | void nx_lvds_set_lvdslocpol0(u32 module_index, u32 regvalue) |
| 204 | { |
| 205 | register struct nx_lvds_register_set *pregister; |
| 206 | |
| 207 | pregister = __g_pregister[module_index]; |
| 208 | writel(regvalue, &pregister->lvdslocpol0); |
| 209 | } |
| 210 | |
| 211 | void nx_lvds_set_lvdslocpol1(u32 module_index, u32 regvalue) |
| 212 | { |
| 213 | register struct nx_lvds_register_set *pregister; |
| 214 | |
| 215 | pregister = __g_pregister[module_index]; |
| 216 | writel(regvalue, &pregister->lvdslocpol1); |
| 217 | } |
| 218 | |
| 219 | void nx_lvds_set_lvdsdummy(u32 module_index, u32 regvalue) |
| 220 | { |
| 221 | register struct nx_lvds_register_set *pregister; |
| 222 | u32 oldvalue; |
| 223 | |
| 224 | pregister = __g_pregister[module_index]; |
| 225 | oldvalue = readl(&pregister->lvdsctrl1) & 0x00ffffff; |
| 226 | writel(oldvalue | ((regvalue & 0xff) << 24), &pregister->lvdsctrl1); |
| 227 | } |
| 228 | |
| 229 | u32 nx_lvds_get_lvdsdummy(u32 module_index) |
| 230 | { |
| 231 | register struct nx_lvds_register_set *pregister; |
| 232 | u32 oldvalue; |
| 233 | |
| 234 | pregister = __g_pregister[module_index]; |
| 235 | oldvalue = readl(&pregister->lvdsctrl1); |
| 236 | oldvalue = oldvalue >> 24; |
| 237 | return oldvalue; |
| 238 | } |
| 239 | |
| 240 | u32 nx_lvds_get_lvdsctrl0(u32 module_index) |
| 241 | { |
| 242 | register struct nx_lvds_register_set *pregister; |
| 243 | |
| 244 | pregister = __g_pregister[module_index]; |
| 245 | return (u32)readl(&pregister->lvdsctrl0); |
| 246 | } |
| 247 | |
| 248 | u32 nx_lvds_get_lvdsctrl1(u32 module_index) |
| 249 | { |
| 250 | register struct nx_lvds_register_set *pregister; |
| 251 | |
| 252 | pregister = __g_pregister[module_index]; |
| 253 | return (u32)readl(&pregister->lvdsctrl1); |
| 254 | } |
| 255 | |
| 256 | u32 nx_lvds_get_lvdsctrl2(u32 module_index) |
| 257 | { |
| 258 | register struct nx_lvds_register_set *pregister; |
| 259 | |
| 260 | pregister = __g_pregister[module_index]; |
| 261 | return (u32)readl(&pregister->lvdsctrl2); |
| 262 | } |
| 263 | |
| 264 | u32 nx_lvds_get_lvdsctrl3(u32 module_index) |
| 265 | { |
| 266 | register struct nx_lvds_register_set *pregister; |
| 267 | |
| 268 | pregister = __g_pregister[module_index]; |
| 269 | return (u32)readl(&pregister->lvdsctrl3); |
| 270 | } |
| 271 | |
| 272 | u32 nx_lvds_get_lvdsctrl4(u32 module_index) |
| 273 | { |
| 274 | register struct nx_lvds_register_set *pregister; |
| 275 | |
| 276 | pregister = __g_pregister[module_index]; |
| 277 | return (u32)readl(&pregister->lvdsctrl4); |
| 278 | } |