| .. | .. |
|---|
| 129 | 129 | return 0; |
|---|
| 130 | 130 | } |
|---|
| 131 | 131 | |
|---|
| 132 | | -EARLYCON_DECLARE(jz4740_uart, ingenic_early_console_setup); |
|---|
| 133 | 132 | OF_EARLYCON_DECLARE(jz4740_uart, "ingenic,jz4740-uart", |
|---|
| 134 | 133 | ingenic_early_console_setup); |
|---|
| 135 | 134 | |
|---|
| 136 | | -EARLYCON_DECLARE(jz4770_uart, ingenic_early_console_setup); |
|---|
| 137 | 135 | OF_EARLYCON_DECLARE(jz4770_uart, "ingenic,jz4770-uart", |
|---|
| 138 | 136 | ingenic_early_console_setup); |
|---|
| 139 | 137 | |
|---|
| 140 | | -EARLYCON_DECLARE(jz4775_uart, ingenic_early_console_setup); |
|---|
| 141 | 138 | OF_EARLYCON_DECLARE(jz4775_uart, "ingenic,jz4775-uart", |
|---|
| 142 | 139 | ingenic_early_console_setup); |
|---|
| 143 | 140 | |
|---|
| 144 | | -EARLYCON_DECLARE(jz4780_uart, ingenic_early_console_setup); |
|---|
| 145 | 141 | OF_EARLYCON_DECLARE(jz4780_uart, "ingenic,jz4780-uart", |
|---|
| 142 | + ingenic_early_console_setup); |
|---|
| 143 | + |
|---|
| 144 | +OF_EARLYCON_DECLARE(x1000_uart, "ingenic,x1000-uart", |
|---|
| 146 | 145 | ingenic_early_console_setup); |
|---|
| 147 | 146 | |
|---|
| 148 | 147 | static void ingenic_uart_serial_out(struct uart_port *p, int offset, int value) |
|---|
| .. | .. |
|---|
| 208 | 207 | static int ingenic_uart_probe(struct platform_device *pdev) |
|---|
| 209 | 208 | { |
|---|
| 210 | 209 | struct uart_8250_port uart = {}; |
|---|
| 211 | | - struct resource *regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
|---|
| 212 | | - struct resource *irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
|---|
| 213 | 210 | struct ingenic_uart_data *data; |
|---|
| 214 | 211 | const struct ingenic_uart_config *cdata; |
|---|
| 215 | 212 | const struct of_device_id *match; |
|---|
| 216 | | - int err, line; |
|---|
| 213 | + struct resource *regs; |
|---|
| 214 | + int irq, err, line; |
|---|
| 217 | 215 | |
|---|
| 218 | 216 | match = of_match_device(of_match, &pdev->dev); |
|---|
| 219 | 217 | if (!match) { |
|---|
| .. | .. |
|---|
| 222 | 220 | } |
|---|
| 223 | 221 | cdata = match->data; |
|---|
| 224 | 222 | |
|---|
| 225 | | - if (!regs || !irq) { |
|---|
| 226 | | - dev_err(&pdev->dev, "no registers/irq defined\n"); |
|---|
| 223 | + irq = platform_get_irq(pdev, 0); |
|---|
| 224 | + if (irq < 0) |
|---|
| 225 | + return irq; |
|---|
| 226 | + |
|---|
| 227 | + regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
|---|
| 228 | + if (!regs) { |
|---|
| 229 | + dev_err(&pdev->dev, "no registers defined\n"); |
|---|
| 227 | 230 | return -EINVAL; |
|---|
| 228 | 231 | } |
|---|
| 229 | 232 | |
|---|
| .. | .. |
|---|
| 239 | 242 | uart.port.regshift = 2; |
|---|
| 240 | 243 | uart.port.serial_out = ingenic_uart_serial_out; |
|---|
| 241 | 244 | uart.port.serial_in = ingenic_uart_serial_in; |
|---|
| 242 | | - uart.port.irq = irq->start; |
|---|
| 245 | + uart.port.irq = irq; |
|---|
| 243 | 246 | uart.port.dev = &pdev->dev; |
|---|
| 244 | 247 | uart.port.fifosize = cdata->fifosize; |
|---|
| 245 | 248 | uart.tx_loadsz = cdata->tx_loadsz; |
|---|
| .. | .. |
|---|
| 256 | 259 | return -ENOMEM; |
|---|
| 257 | 260 | |
|---|
| 258 | 261 | data->clk_module = devm_clk_get(&pdev->dev, "module"); |
|---|
| 259 | | - if (IS_ERR(data->clk_module)) { |
|---|
| 260 | | - err = PTR_ERR(data->clk_module); |
|---|
| 261 | | - if (err != -EPROBE_DEFER) |
|---|
| 262 | | - dev_err(&pdev->dev, |
|---|
| 263 | | - "unable to get module clock: %d\n", err); |
|---|
| 264 | | - return err; |
|---|
| 265 | | - } |
|---|
| 262 | + if (IS_ERR(data->clk_module)) |
|---|
| 263 | + return dev_err_probe(&pdev->dev, PTR_ERR(data->clk_module), |
|---|
| 264 | + "unable to get module clock\n"); |
|---|
| 266 | 265 | |
|---|
| 267 | 266 | data->clk_baud = devm_clk_get(&pdev->dev, "baud"); |
|---|
| 268 | | - if (IS_ERR(data->clk_baud)) { |
|---|
| 269 | | - err = PTR_ERR(data->clk_baud); |
|---|
| 270 | | - if (err != -EPROBE_DEFER) |
|---|
| 271 | | - dev_err(&pdev->dev, |
|---|
| 272 | | - "unable to get baud clock: %d\n", err); |
|---|
| 273 | | - return err; |
|---|
| 274 | | - } |
|---|
| 267 | + if (IS_ERR(data->clk_baud)) |
|---|
| 268 | + return dev_err_probe(&pdev->dev, PTR_ERR(data->clk_baud), |
|---|
| 269 | + "unable to get baud clock\n"); |
|---|
| 275 | 270 | |
|---|
| 276 | 271 | err = clk_prepare_enable(data->clk_module); |
|---|
| 277 | 272 | if (err) { |
|---|
| .. | .. |
|---|
| 328 | 323 | .fifosize = 64, |
|---|
| 329 | 324 | }; |
|---|
| 330 | 325 | |
|---|
| 326 | +static const struct ingenic_uart_config x1000_uart_config = { |
|---|
| 327 | + .tx_loadsz = 32, |
|---|
| 328 | + .fifosize = 64, |
|---|
| 329 | +}; |
|---|
| 330 | + |
|---|
| 331 | 331 | static const struct of_device_id of_match[] = { |
|---|
| 332 | 332 | { .compatible = "ingenic,jz4740-uart", .data = &jz4740_uart_config }, |
|---|
| 333 | 333 | { .compatible = "ingenic,jz4760-uart", .data = &jz4760_uart_config }, |
|---|
| 334 | 334 | { .compatible = "ingenic,jz4770-uart", .data = &jz4760_uart_config }, |
|---|
| 335 | 335 | { .compatible = "ingenic,jz4775-uart", .data = &jz4760_uart_config }, |
|---|
| 336 | 336 | { .compatible = "ingenic,jz4780-uart", .data = &jz4780_uart_config }, |
|---|
| 337 | + { .compatible = "ingenic,x1000-uart", .data = &x1000_uart_config }, |
|---|
| 337 | 338 | { /* sentinel */ } |
|---|
| 338 | 339 | }; |
|---|
| 339 | 340 | MODULE_DEVICE_TABLE(of, of_match); |
|---|