Loading drivers/spi/spi-bcm2835aux.c +56 −0 Original line number Original line Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include <linux/clk.h> #include <linux/clk.h> #include <linux/completion.h> #include <linux/completion.h> #include <linux/debugfs.h> #include <linux/delay.h> #include <linux/delay.h> #include <linux/err.h> #include <linux/err.h> #include <linux/interrupt.h> #include <linux/interrupt.h> Loading Loading @@ -104,8 +105,52 @@ struct bcm2835aux_spi { int tx_len; int tx_len; int rx_len; int rx_len; int pending; int pending; u64 count_transfer_polling; u64 count_transfer_irq; u64 count_transfer_irq_after_poll; struct dentry *debugfs_dir; }; }; #if defined(CONFIG_DEBUG_FS) static void bcm2835aux_debugfs_create(struct bcm2835aux_spi *bs, const char *dname) { char name[64]; struct dentry *dir; /* get full name */ snprintf(name, sizeof(name), "spi-bcm2835aux-%s", dname); /* the base directory */ dir = debugfs_create_dir(name, NULL); bs->debugfs_dir = dir; /* the counters */ debugfs_create_u64("count_transfer_polling", 0444, dir, &bs->count_transfer_polling); debugfs_create_u64("count_transfer_irq", 0444, dir, &bs->count_transfer_irq); debugfs_create_u64("count_transfer_irq_after_poll", 0444, dir, &bs->count_transfer_irq_after_poll); } static void bcm2835aux_debugfs_remove(struct bcm2835aux_spi *bs) { debugfs_remove_recursive(bs->debugfs_dir); bs->debugfs_dir = NULL; } #else static void bcm2835aux_debugfs_create(struct bcm2835aux_spi *bs) { } static void bcm2835aux_debugfs_remove(struct bcm2835aux_spi *bs) { } #endif /* CONFIG_DEBUG_FS */ static inline u32 bcm2835aux_rd(struct bcm2835aux_spi *bs, unsigned reg) static inline u32 bcm2835aux_rd(struct bcm2835aux_spi *bs, unsigned reg) { { return readl(bs->regs + reg); return readl(bs->regs + reg); Loading Loading @@ -244,6 +289,9 @@ static int bcm2835aux_spi_transfer_one_irq(struct spi_master *master, { { struct bcm2835aux_spi *bs = spi_master_get_devdata(master); struct bcm2835aux_spi *bs = spi_master_get_devdata(master); /* update statistics */ bs->count_transfer_irq++; /* fill in registers and fifos before enabling interrupts */ /* fill in registers and fifos before enabling interrupts */ bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL1, bs->cntl[1]); bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL1, bs->cntl[1]); bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL0, bs->cntl[0]); bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL0, bs->cntl[0]); Loading @@ -267,6 +315,9 @@ static int bcm2835aux_spi_transfer_one_poll(struct spi_master *master, struct bcm2835aux_spi *bs = spi_master_get_devdata(master); struct bcm2835aux_spi *bs = spi_master_get_devdata(master); unsigned long timeout; unsigned long timeout; /* update statistics */ bs->count_transfer_polling++; /* configure spi */ /* configure spi */ bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL1, bs->cntl[1]); bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL1, bs->cntl[1]); bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL0, bs->cntl[0]); bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL0, bs->cntl[0]); Loading @@ -287,6 +338,7 @@ static int bcm2835aux_spi_transfer_one_poll(struct spi_master *master, jiffies - timeout, jiffies - timeout, bs->tx_len, bs->rx_len); bs->tx_len, bs->rx_len); /* forward to interrupt handler */ /* forward to interrupt handler */ bs->count_transfer_irq_after_poll++; return __bcm2835aux_spi_transfer_one_irq(master, return __bcm2835aux_spi_transfer_one_irq(master, spi, tfr); spi, tfr); } } Loading Loading @@ -536,6 +588,8 @@ static int bcm2835aux_spi_probe(struct platform_device *pdev) goto out_clk_disable; goto out_clk_disable; } } bcm2835aux_debugfs_create(bs, dev_name(&pdev->dev)); return 0; return 0; out_clk_disable: out_clk_disable: Loading @@ -550,6 +604,8 @@ static int bcm2835aux_spi_remove(struct platform_device *pdev) struct spi_master *master = platform_get_drvdata(pdev); struct spi_master *master = platform_get_drvdata(pdev); struct bcm2835aux_spi *bs = spi_master_get_devdata(master); struct bcm2835aux_spi *bs = spi_master_get_devdata(master); bcm2835aux_debugfs_remove(bs); bcm2835aux_spi_reset_hw(bs); bcm2835aux_spi_reset_hw(bs); /* disable the HW block by releasing the clock */ /* disable the HW block by releasing the clock */ Loading Loading
drivers/spi/spi-bcm2835aux.c +56 −0 Original line number Original line Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include <linux/clk.h> #include <linux/clk.h> #include <linux/completion.h> #include <linux/completion.h> #include <linux/debugfs.h> #include <linux/delay.h> #include <linux/delay.h> #include <linux/err.h> #include <linux/err.h> #include <linux/interrupt.h> #include <linux/interrupt.h> Loading Loading @@ -104,8 +105,52 @@ struct bcm2835aux_spi { int tx_len; int tx_len; int rx_len; int rx_len; int pending; int pending; u64 count_transfer_polling; u64 count_transfer_irq; u64 count_transfer_irq_after_poll; struct dentry *debugfs_dir; }; }; #if defined(CONFIG_DEBUG_FS) static void bcm2835aux_debugfs_create(struct bcm2835aux_spi *bs, const char *dname) { char name[64]; struct dentry *dir; /* get full name */ snprintf(name, sizeof(name), "spi-bcm2835aux-%s", dname); /* the base directory */ dir = debugfs_create_dir(name, NULL); bs->debugfs_dir = dir; /* the counters */ debugfs_create_u64("count_transfer_polling", 0444, dir, &bs->count_transfer_polling); debugfs_create_u64("count_transfer_irq", 0444, dir, &bs->count_transfer_irq); debugfs_create_u64("count_transfer_irq_after_poll", 0444, dir, &bs->count_transfer_irq_after_poll); } static void bcm2835aux_debugfs_remove(struct bcm2835aux_spi *bs) { debugfs_remove_recursive(bs->debugfs_dir); bs->debugfs_dir = NULL; } #else static void bcm2835aux_debugfs_create(struct bcm2835aux_spi *bs) { } static void bcm2835aux_debugfs_remove(struct bcm2835aux_spi *bs) { } #endif /* CONFIG_DEBUG_FS */ static inline u32 bcm2835aux_rd(struct bcm2835aux_spi *bs, unsigned reg) static inline u32 bcm2835aux_rd(struct bcm2835aux_spi *bs, unsigned reg) { { return readl(bs->regs + reg); return readl(bs->regs + reg); Loading Loading @@ -244,6 +289,9 @@ static int bcm2835aux_spi_transfer_one_irq(struct spi_master *master, { { struct bcm2835aux_spi *bs = spi_master_get_devdata(master); struct bcm2835aux_spi *bs = spi_master_get_devdata(master); /* update statistics */ bs->count_transfer_irq++; /* fill in registers and fifos before enabling interrupts */ /* fill in registers and fifos before enabling interrupts */ bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL1, bs->cntl[1]); bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL1, bs->cntl[1]); bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL0, bs->cntl[0]); bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL0, bs->cntl[0]); Loading @@ -267,6 +315,9 @@ static int bcm2835aux_spi_transfer_one_poll(struct spi_master *master, struct bcm2835aux_spi *bs = spi_master_get_devdata(master); struct bcm2835aux_spi *bs = spi_master_get_devdata(master); unsigned long timeout; unsigned long timeout; /* update statistics */ bs->count_transfer_polling++; /* configure spi */ /* configure spi */ bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL1, bs->cntl[1]); bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL1, bs->cntl[1]); bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL0, bs->cntl[0]); bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL0, bs->cntl[0]); Loading @@ -287,6 +338,7 @@ static int bcm2835aux_spi_transfer_one_poll(struct spi_master *master, jiffies - timeout, jiffies - timeout, bs->tx_len, bs->rx_len); bs->tx_len, bs->rx_len); /* forward to interrupt handler */ /* forward to interrupt handler */ bs->count_transfer_irq_after_poll++; return __bcm2835aux_spi_transfer_one_irq(master, return __bcm2835aux_spi_transfer_one_irq(master, spi, tfr); spi, tfr); } } Loading Loading @@ -536,6 +588,8 @@ static int bcm2835aux_spi_probe(struct platform_device *pdev) goto out_clk_disable; goto out_clk_disable; } } bcm2835aux_debugfs_create(bs, dev_name(&pdev->dev)); return 0; return 0; out_clk_disable: out_clk_disable: Loading @@ -550,6 +604,8 @@ static int bcm2835aux_spi_remove(struct platform_device *pdev) struct spi_master *master = platform_get_drvdata(pdev); struct spi_master *master = platform_get_drvdata(pdev); struct bcm2835aux_spi *bs = spi_master_get_devdata(master); struct bcm2835aux_spi *bs = spi_master_get_devdata(master); bcm2835aux_debugfs_remove(bs); bcm2835aux_spi_reset_hw(bs); bcm2835aux_spi_reset_hw(bs); /* disable the HW block by releasing the clock */ /* disable the HW block by releasing the clock */ Loading