0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <dt-bindings/mfd/at91-usart.h>
0012
0013 #include <linux/module.h>
0014 #include <linux/mfd/core.h>
0015 #include <linux/of.h>
0016 #include <linux/property.h>
0017
0018 static const struct mfd_cell at91_usart_spi_subdev =
0019 MFD_CELL_NAME("at91_usart_spi");
0020
0021 static const struct mfd_cell at91_usart_serial_subdev =
0022 MFD_CELL_NAME("atmel_usart_serial");
0023
0024 static int at91_usart_mode_probe(struct platform_device *pdev)
0025 {
0026 const struct mfd_cell *cell;
0027 u32 opmode = AT91_USART_MODE_SERIAL;
0028
0029 device_property_read_u32(&pdev->dev, "atmel,usart-mode", &opmode);
0030
0031 switch (opmode) {
0032 case AT91_USART_MODE_SPI:
0033 cell = &at91_usart_spi_subdev;
0034 break;
0035 case AT91_USART_MODE_SERIAL:
0036 cell = &at91_usart_serial_subdev;
0037 break;
0038 default:
0039 dev_err(&pdev->dev, "atmel,usart-mode has an invalid value %u\n",
0040 opmode);
0041 return -EINVAL;
0042 }
0043
0044 return devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_AUTO, cell, 1,
0045 NULL, 0, NULL);
0046 }
0047
0048 static const struct of_device_id at91_usart_mode_of_match[] = {
0049 { .compatible = "atmel,at91rm9200-usart" },
0050 { .compatible = "atmel,at91sam9260-usart" },
0051 { }
0052 };
0053
0054 MODULE_DEVICE_TABLE(of, at91_usart_mode_of_match);
0055
0056 static struct platform_driver at91_usart_mfd = {
0057 .probe = at91_usart_mode_probe,
0058 .driver = {
0059 .name = "at91_usart_mode",
0060 .of_match_table = at91_usart_mode_of_match,
0061 },
0062 };
0063
0064 module_platform_driver(at91_usart_mfd);
0065
0066 MODULE_AUTHOR("Radu Pirea <radu.pirea@microchip.com>");
0067 MODULE_DESCRIPTION("AT91 USART MFD driver");
0068 MODULE_LICENSE("GPL v2");