Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Test SPI DMA
- *
- * Copyright (C) 2020 Cirrus Logic, Inc. and
- * Cirrus Logic International Semiconductor Ltd.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
- #include <linux/module.h>
- #include <linux/err.h>
- #include <linux/spi/spi.h>
- #include <linux/regmap.h>
- #define TEST_SIZE 20428
- static struct regmap_config test_spi_regmap = {
- .name = "test_spi",
- .reg_bits = 32,
- .pad_bits = 32,
- .val_bits = 32,
- .reg_stride = 4,
- .max_register = 0xFFFFFFFF,
- .cache_type = REGCACHE_NONE,
- };
- static int test_spi_probe(struct spi_device *spi)
- {
- int i, ret = 0;
- struct regmap *regmap;
- char *buffer;
- char *buffer2;
- pr_info("%s",__func__);
- regmap = devm_regmap_init_spi(spi, &test_spi_regmap);
- if (IS_ERR(regmap)) {
- ret = PTR_ERR(regmap);
- dev_err(&spi->dev, "Failed to allocate register map: %d\n", ret);
- }
- buffer = vmalloc(TEST_SIZE);
- buffer2 = kmalloc(TEST_SIZE, GFP_KERNEL);
- for (i = 0; i < TEST_SIZE; i++){
- buffer[i] = i % 0xff;
- buffer2[i] = i % 0xff;
- }
- regmap_raw_write(regmap, 0, buffer, TEST_SIZE);
- mdelay(50);
- regmap_raw_write(regmap, 0, buffer2, TEST_SIZE);
- kfree(buffer);
- return ret;
- }
- static const struct of_device_id test_spi_match[] = {
- { .compatible = "spi-dma-test", },
- {},
- };
- MODULE_DEVICE_TABLE(of, test_spi_match);
- static struct spi_driver test_spi_driver = {
- .driver = {
- .name = "spi-dma-test",
- .of_match_table = test_spi_match,
- },
- .probe = &test_spi_probe,
- };
- module_spi_driver(test_spi_driver);
- MODULE_DESCRIPTION("Test RPI4 SPI BUG");
- MODULE_AUTHOR("Lucas Tanure <[email protected]>");
- MODULE_LICENSE("GPL v2");
- ###################################################################################################
- Device tree
- /dts-v1/;
- /plugin/;
- / {
- compatible = "brcm,bcm2835";
- fragment@0 {
- target = <&spi0>;
- __overlay__ {
- #address-cells = <1>;
- #size-cells = <0>;
- status = "okay";
- spidev@1{
- status = "disabled";
- };
- spi_test@1{
- spi-max-frequency = <12500000>;
- reg = <1>;
- compatible = "spi-dma-test";
- };
- };
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment