From: Thomas Chou <thomas@wytron.com.tw>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 4/8] mips: ath79: add serial driver for ar933x SOC
Date: Sun, 27 Dec 2015 16:31:17 +0800 [thread overview]
Message-ID: <567FA1D5.7090106@wytron.com.tw> (raw)
In-Reply-To: <567E941C.9090300@gmail.com>
Hi Wills,
On 2015?12?26? 21:20, Daniel Schwierzeck wrote:
>> +static int ar933x_serial_probe(struct udevice *dev)
>> +{
>> + struct ar933x_serial_priv *priv = dev_get_priv(dev);
>> + struct ar933x_serial_platdata *plat = dev_get_platdata(dev);
>> + u32 val;
>> +
>> + priv->regs = plat->regs;
>> +
>> + /*
>> + * UART controller configuration:
>> + * - no DMA
>> + * - no interrupt
>> + * - DCE mode
>> + * - no flow control
>> + * - set RX ready oride
>> + * - set TX ready oride
>> + */
>> + val = (AR933X_UART_CS_IF_MODE_DCE << AR933X_UART_CS_IF_MODE_S) |
>> + AR933X_UART_CS_TX_RDY_ORIDE | AR933X_UART_CS_RX_RDY_ORIDE;
>> + ar933x_serial_write(dev, val, AR933X_UART_CS_REG);
>> + return 0;
>> +}
>> +
>> +static int ar933x_serial_ofdata_to_platdata(struct udevice *dev)
>> +{
>> + struct ar933x_serial_platdata *plat = dev_get_platdata(dev);
>> + fdt_addr_t addr;
>> +
>> + addr = dev_get_addr(dev);
>> + if (addr == FDT_ADDR_T_NONE)
>> + return -EINVAL;
>> +
>> + plat->regs = map_physmem(addr,
>> + AR933X_UART_SIZE,
>> + MAP_NOCACHE);
>
> move this code to function ar933x_serial_probe and drop this function
>
>> + return 0;
>> +}
>> +
>> +static const struct dm_serial_ops ar933x_serial_ops = {
>> + .putc = ar933x_serial_putc,
>> + .pending = ar933x_serial_pending,
>> + .getc = ar933x_serial_getc,
>> + .setbrg = ar933x_serial_setbrg,
>> +};
>> +
>> +static const struct udevice_id ar933x_serial_ids[] = {
>> + { .compatible = "ath79,ar933x-uart" },
>> + { }
>> +};
>> +
>> +U_BOOT_DRIVER(serial_ar933x) = {
>> + .name = "serial_ar933x",
>> + .id = UCLASS_SERIAL,
>> + .of_match = ar933x_serial_ids,
>> + .ofdata_to_platdata = ar933x_serial_ofdata_to_platdata,
>> + .platdata_auto_alloc_size = sizeof(struct ar933x_serial_platdata),
>
> drop the two lines, you do not need to allocate platdata
>
It might be another option to keep platdata and ofdata_to_platdata(),
and remove the priv data. Let ofdata_to_platdata() do the DT conversion
and probe() detect and initialize the hardware. This is what these func
expected to do. The priv data is needed only when there is variable data
to save per device.
Best regards,
Thomas
next prev parent reply other threads:[~2015-12-27 8:31 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1451069788-6786-1-git-send-email-wills.wang@live.com>
2015-12-25 18:56 ` [U-Boot] [PATCH v4 1/8] include: Add support for "do_div" macro Wills Wang
2015-12-26 7:24 ` Marek Vasut
2015-12-26 15:48 ` Wills Wang
2015-12-26 13:09 ` Daniel Schwierzeck
2015-12-26 16:54 ` Wills Wang
2015-12-25 18:56 ` [U-Boot] [PATCH v4 2/8] mips: implement to access the KSEG0/1 memory range in map_physmem Wills Wang
2015-12-26 7:25 ` Marek Vasut
2015-12-25 18:56 ` [U-Boot] [PATCH v4 3/8] mips: add base support for atheros ath79 based SOCs Wills Wang
2015-12-26 7:28 ` Marek Vasut
2015-12-26 16:17 ` Wills Wang
2015-12-26 17:01 ` Daniel Schwierzeck
2015-12-26 17:06 ` Marek Vasut
2015-12-27 9:37 ` Wills Wang
2015-12-25 18:56 ` [U-Boot] [PATCH v4 4/8] mips: ath79: add serial driver for ar933x SOC Wills Wang
2015-12-26 13:20 ` Daniel Schwierzeck
2015-12-26 16:54 ` Wills Wang
2015-12-26 17:19 ` Daniel Schwierzeck
2015-12-27 6:28 ` Wills Wang
2015-12-27 8:21 ` Thomas Chou
2015-12-27 13:07 ` Thomas Chou
2015-12-27 8:31 ` Thomas Chou [this message]
2015-12-25 18:56 ` [U-Boot] [PATCH v4 5/8] mips: ath79: add spi driver Wills Wang
2015-12-26 13:23 ` Daniel Schwierzeck
2015-12-26 16:56 ` Wills Wang
2015-12-25 18:56 ` [U-Boot] [PATCH v4 6/8] mips: ath79: add AP121 reference board Wills Wang
2015-12-26 13:52 ` Daniel Schwierzeck
2015-12-26 16:59 ` Wills Wang
2015-12-26 17:07 ` Daniel Schwierzeck
2015-12-27 6:36 ` Wills Wang
2015-12-27 6:41 ` Marek Vasut
2015-12-27 7:03 ` Wills Wang
2015-12-27 7:10 ` Marek Vasut
2015-12-25 18:56 ` [U-Boot] [PATCH v4 7/8] mips: support optimize tuning for same common processor cores Wills Wang
2015-12-26 7:30 ` Marek Vasut
2015-12-26 18:58 ` Daniel Schwierzeck
2015-12-27 3:03 ` Wills Wang
2015-12-25 18:56 ` [U-Boot] [PATCH v4 8/8] mips: move optimize tuning option from deprecated config.mk to Kconfig Wills Wang
2015-12-26 7:30 ` Marek Vasut
2015-12-26 17:33 ` Wills Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=567FA1D5.7090106@wytron.com.tw \
--to=thomas@wytron.com.tw \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox