Merge remote-tracking branches 'spi/topic/sh-msiof', 'spi/topic/stm32', 'spi/topic...
authorMark Brown <broonie@kernel.org>
Mon, 4 Sep 2017 14:51:30 +0000 (15:51 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 4 Sep 2017 14:51:30 +0000 (15:51 +0100)
Documentation/devicetree/bindings/spi/sh-msiof.txt
drivers/spi/spi-sh-msiof.c
drivers/spi/spi-stm32.c
drivers/spi/spi-sun6i.c
drivers/spi/spi-tegra114.c
drivers/spi/spi-tegra20-sflash.c
drivers/spi/spi-tegra20-slink.c
tools/Makefile
tools/spi/Build [new file with mode: 0644]
tools/spi/Makefile

index 64ee489571c42f88a13decf8e0a1679f635f636c..39e5ef7c5e71694eeb6d1ccba4499d0cdd8b125e 100644 (file)
@@ -6,6 +6,7 @@ Required properties:
                         "renesas,msiof-r8a7792" (R-Car V2H)
                         "renesas,msiof-r8a7793" (R-Car M2-N)
                         "renesas,msiof-r8a7794" (R-Car E2)
+                        "renesas,msiof-r8a7795" (R-Car H3)
                         "renesas,msiof-r8a7796" (R-Car M3-W)
                         "renesas,msiof-sh73a0" (SH-Mobile AG5)
                         "renesas,sh-mobile-msiof" (generic SH-Mobile compatibile device)
index c304c7167866d2dbc9fdfcff902729eefb2db78e..0eb1e95834854fb658806b1aaefc19fb7bec69b3 100644 (file)
@@ -38,6 +38,7 @@ struct sh_msiof_chipdata {
        u16 tx_fifo_size;
        u16 rx_fifo_size;
        u16 master_flags;
+       u16 min_div;
 };
 
 struct sh_msiof_spi_priv {
@@ -49,6 +50,7 @@ struct sh_msiof_spi_priv {
        struct completion done;
        unsigned int tx_fifo_size;
        unsigned int rx_fifo_size;
+       unsigned int min_div;
        void *tx_dma_page;
        void *rx_dma_page;
        dma_addr_t tx_dma_addr;
@@ -261,6 +263,8 @@ static void sh_msiof_spi_set_clk_regs(struct sh_msiof_spi_priv *p,
        if (!WARN_ON(!spi_hz || !parent_rate))
                div = DIV_ROUND_UP(parent_rate, spi_hz);
 
+       div = max_t(unsigned long, div, p->min_div);
+
        for (k = 0; k < ARRAY_SIZE(sh_msiof_spi_div_table); k++) {
                brps = DIV_ROUND_UP(div, sh_msiof_spi_div_table[k].div);
                /* SCR_BRDV_DIV_1 is valid only if BRPS is x 1/1 or x 1/2 */
@@ -998,24 +1002,33 @@ static const struct sh_msiof_chipdata sh_data = {
        .tx_fifo_size = 64,
        .rx_fifo_size = 64,
        .master_flags = 0,
+       .min_div = 1,
+};
+
+static const struct sh_msiof_chipdata rcar_gen2_data = {
+       .tx_fifo_size = 64,
+       .rx_fifo_size = 64,
+       .master_flags = SPI_MASTER_MUST_TX,
+       .min_div = 1,
 };
 
-static const struct sh_msiof_chipdata r8a779x_data = {
+static const struct sh_msiof_chipdata rcar_gen3_data = {
        .tx_fifo_size = 64,
        .rx_fifo_size = 64,
        .master_flags = SPI_MASTER_MUST_TX,
+       .min_div = 2,
 };
 
 static const struct of_device_id sh_msiof_match[] = {
        { .compatible = "renesas,sh-mobile-msiof", .data = &sh_data },
-       { .compatible = "renesas,msiof-r8a7790",   .data = &r8a779x_data },
-       { .compatible = "renesas,msiof-r8a7791",   .data = &r8a779x_data },
-       { .compatible = "renesas,msiof-r8a7792",   .data = &r8a779x_data },
-       { .compatible = "renesas,msiof-r8a7793",   .data = &r8a779x_data },
-       { .compatible = "renesas,msiof-r8a7794",   .data = &r8a779x_data },
-       { .compatible = "renesas,rcar-gen2-msiof", .data = &r8a779x_data },
-       { .compatible = "renesas,msiof-r8a7796",   .data = &r8a779x_data },
-       { .compatible = "renesas,rcar-gen3-msiof", .data = &r8a779x_data },
+       { .compatible = "renesas,msiof-r8a7790",   .data = &rcar_gen2_data },
+       { .compatible = "renesas,msiof-r8a7791",   .data = &rcar_gen2_data },
+       { .compatible = "renesas,msiof-r8a7792",   .data = &rcar_gen2_data },
+       { .compatible = "renesas,msiof-r8a7793",   .data = &rcar_gen2_data },
+       { .compatible = "renesas,msiof-r8a7794",   .data = &rcar_gen2_data },
+       { .compatible = "renesas,rcar-gen2-msiof", .data = &rcar_gen2_data },
+       { .compatible = "renesas,msiof-r8a7796",   .data = &rcar_gen3_data },
+       { .compatible = "renesas,rcar-gen3-msiof", .data = &rcar_gen3_data },
        { .compatible = "renesas,sh-msiof",        .data = &sh_data }, /* Deprecated */
        {},
 };
@@ -1230,6 +1243,7 @@ static int sh_msiof_spi_probe(struct platform_device *pdev)
        platform_set_drvdata(pdev, p);
        p->master = master;
        p->info = info;
+       p->min_div = chipdata->min_div;
 
        init_completion(&p->done);
 
index 75644bcd938b6d5635505e4da2938d7cb689f90f..680cdf549506143d6041736f43552f868e3bf6db 100644 (file)
@@ -1132,7 +1132,7 @@ static int stm32_spi_probe(struct platform_device *pdev)
                goto err_master_put;
        }
 
-       spi->rst = devm_reset_control_get(&pdev->dev, NULL);
+       spi->rst = devm_reset_control_get_exclusive(&pdev->dev, NULL);
        if (!IS_ERR(spi->rst)) {
                reset_control_assert(spi->rst);
                udelay(2);
index 03a773a9531a9d08944c4e5142f1668a3d3f2b6c..fb38234249a80055dc17212829ea2adafa3b43fe 100644 (file)
@@ -502,7 +502,7 @@ static int sun6i_spi_probe(struct platform_device *pdev)
 
        init_completion(&sspi->done);
 
-       sspi->rstc = devm_reset_control_get(&pdev->dev, NULL);
+       sspi->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
        if (IS_ERR(sspi->rstc)) {
                dev_err(&pdev->dev, "Couldn't get reset controller\n");
                ret = PTR_ERR(sspi->rstc);
index 08012ae5aa66eb3c03396523e5d25a3dc2101c64..44550182a4a364e53ba1b62da634ca6362d2df90 100644 (file)
@@ -1083,7 +1083,7 @@ static int tegra_spi_probe(struct platform_device *pdev)
                goto exit_free_irq;
        }
 
-       tspi->rst = devm_reset_control_get(&pdev->dev, "spi");
+       tspi->rst = devm_reset_control_get_exclusive(&pdev->dev, "spi");
        if (IS_ERR(tspi->rst)) {
                dev_err(&pdev->dev, "can not get reset\n");
                ret = PTR_ERR(tspi->rst);
index 2c797ee2664dee454b308e23f4b46169e7b54cc0..22893a7e0aa0ea896dad668cfcfb24112bf1c6fb 100644 (file)
@@ -485,7 +485,7 @@ static int tegra_sflash_probe(struct platform_device *pdev)
                goto exit_free_irq;
        }
 
-       tsd->rst = devm_reset_control_get(&pdev->dev, "spi");
+       tsd->rst = devm_reset_control_get_exclusive(&pdev->dev, "spi");
        if (IS_ERR(tsd->rst)) {
                dev_err(&pdev->dev, "can not get reset\n");
                ret = PTR_ERR(tsd->rst);
index 0c06ce424210a692f80305f2eadef1b2e6a179af..3e12d5f87ee4412b086649c8f2312fb3cc9e30a8 100644 (file)
@@ -1081,7 +1081,7 @@ static int tegra_slink_probe(struct platform_device *pdev)
                goto exit_free_irq;
        }
 
-       tspi->rst = devm_reset_control_get(&pdev->dev, "spi");
+       tspi->rst = devm_reset_control_get_exclusive(&pdev->dev, "spi");
        if (IS_ERR(tspi->rst)) {
                dev_err(&pdev->dev, "can not get reset\n");
                ret = PTR_ERR(tspi->rst);
index 221e1ce78b06bb43bb344b36e01cd6dd72b10feb..616e7722b327be54d43c1157904ead0c886565b4 100644 (file)
@@ -91,7 +91,7 @@ kvm_stat: FORCE
        $(call descend,kvm/$@)
 
 all: acpi cgroup cpupower gpio hv firewire lguest liblockdep \
-               perf selftests turbostat usb \
+               perf selftests spi turbostat usb \
                virtio vm net x86_energy_perf_policy \
                tmon freefall objtool kvm_stat
 
@@ -101,7 +101,7 @@ acpi_install:
 cpupower_install:
        $(call descend,power/$(@:_install=),install)
 
-cgroup_install firewire_install gpio_install hv_install lguest_install perf_install usb_install virtio_install vm_install net_install objtool_install:
+cgroup_install firewire_install gpio_install hv_install lguest_install perf_install spi_install usb_install virtio_install vm_install net_install objtool_install:
        $(call descend,$(@:_install=),install)
 
 liblockdep_install:
diff --git a/tools/spi/Build b/tools/spi/Build
new file mode 100644 (file)
index 0000000..8e84660
--- /dev/null
@@ -0,0 +1,2 @@
+spidev_test-y += spidev_test.o
+spidev_fdx-y += spidev_fdx.o
index 3815b18ba0703631de16203bdf3087a40e1a4757..90615e10c79af1c766f0d9a629bdac862f7cb507 100644 (file)
@@ -1,6 +1,66 @@
+include ../scripts/Makefile.include
+
+bindir ?= /usr/bin
+
+ifeq ($(srctree),)
+srctree := $(patsubst %/,%,$(dir $(CURDIR)))
+srctree := $(patsubst %/,%,$(dir $(srctree)))
+endif
+
+# Do not use make's built-in rules
+# (this improves performance and avoids hard-to-debug behaviour);
+MAKEFLAGS += -r
+
 CC = $(CROSS_COMPILE)gcc
+LD = $(CROSS_COMPILE)ld
+CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
+
+ALL_TARGETS := spidev_test spidev_fdx
+ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
+
+all: $(ALL_PROGRAMS)
+
+export srctree OUTPUT CC LD CFLAGS
+include $(srctree)/tools/build/Makefile.include
 
-all: spidev_test spidev_fdx
+#
+# We need the following to be outside of kernel tree
+#
+$(OUTPUT)include/linux/spi/spidev.h: ../../include/uapi/linux/spi/spidev.h
+       mkdir -p $(OUTPUT)include/linux/spi 2>&1 || true
+       ln -sf $(CURDIR)/../../include/uapi/linux/spi/spidev.h $@
+
+prepare: $(OUTPUT)include/linux/spi/spidev.h
+
+#
+# spidev_test
+#
+SPIDEV_TEST_IN := $(OUTPUT)spidev_test-in.o
+$(SPIDEV_TEST_IN): prepare FORCE
+       $(Q)$(MAKE) $(build)=spidev_test
+$(OUTPUT)spidev_test: $(SPIDEV_TEST_IN)
+       $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
+
+#
+# spidev_fdx
+#
+SPIDEV_FDX_IN := $(OUTPUT)spidev_fdx-in.o
+$(SPIDEV_FDX_IN): prepare FORCE
+       $(Q)$(MAKE) $(build)=spidev_fdx
+$(OUTPUT)spidev_fdx: $(SPIDEV_FDX_IN)
+       $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
 
 clean:
-       $(RM) spidev_test spidev_fdx
+       rm -f $(ALL_PROGRAMS)
+       rm -f $(OUTPUT)include/linux/spi/spidev.h
+       find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
+
+install: $(ALL_PROGRAMS)
+       install -d -m 755 $(DESTDIR)$(bindir);          \
+       for program in $(ALL_PROGRAMS); do              \
+               install $$program $(DESTDIR)$(bindir);  \
+       done
+
+FORCE:
+
+.PHONY: all install clean FORCE prepare