drivers/spi/oc_tiny_spi.c | 422 +++++++++++++++++++++++++++++++++++++++
Rename files to spi_oc_tiny.c
+#ifndef CONFIG_TINY_SPI_IDLE_VAL
+# define CONFIG_TINY_SPI_IDLE_VAL 0x00
+#endif
Do you really want this as a Kconfig symbol? Looks like something
that should be configured in pdata or the device tree.
+ if (t->len> 1) {
+ writeb(CONFIG_TINY_SPI_IDLE_VAL,
+ hw->base + TINY_SPI_TXDATA);
+ for (i = 2; i< t->len; i++) {
+ while (!(readb(hw->base + TINY_SPI_STATUS)&
+ TINY_SPI_STATUS_TXR))
+ cpu_relax();
+ writeb(CONFIG_TINY_SPI_IDLE_VAL,
+ hw->base + TINY_SPI_TXDATA);
+ }
+ }
+ while (!(readb(hw->base + TINY_SPI_STATUS)&
+ TINY_SPI_STATUS_TXE))
+ cpu_relax();
I see a bunch of while loops in this function with no exit condition
if something goes badly with the hardware. Also, this driver is going
to chew up *a lot* of cpu cycles when not using irqs. Consider
putting the polled work into a tasklet instead of blindly spinning.
It will actually make the driver simpler because the irq and non-irq
cases become very similar.
+ hw->bitbang.master->dev.of_node = pdev->dev.of_node;
+ val = of_get_property(pdev->dev.of_node, "baud-width", NULL);
'baud-width'?
These properties need to be documented. See below.
+#ifdef CONFIG_OF
+static struct of_device_id oc_tiny_spi_match[] = {
+ {
+ .compatible = "opencores,oc_tiny_spi",
If this is a soft core, then there should be a version number of some
sort on the compatible value. Also, please use dash '-' instead of
underscore '_' in compatible values. Also, for all of these new
bindings, they need to be documented. Please add documentation to
Documentation/powerpc/dts-bindings (yes, I know, this is not
for powerpc, but that is the established directory. I'll move it to a
better location soon).
Finally, one nitpick. For conciseness, most of_device_id tables are
written in the form:
static struct of_device_id oc_tiny_spi_match[] = {
{ .compatible = "opencores,oc_tiny_spi", }, },
{},
}
+static int __init tiny_spi_init(void)
+{
+ return platform_driver_probe(&tiny_spidrv, tiny_spi_probe);
+}
+module_init(tiny_spi_init);
Please use platform_driver_register, and put your probe function into
the platform_driver structure.