Skip to content

Commit

Permalink
Add SMI driver
Browse files Browse the repository at this point in the history
Signed-off-by: Luke Wren <wren6991@gmail.com>

MISC: bcm2835: smi: use clock manager and fix reload issues

Use clock manager instead of self-made clockmanager.

Also fix some error paths that showd up during development
(especially missing release of dma resources on rmmod)

Signed-off-by: Martin Sperl <kernel@martin.sperl.org>

bcm2835_smi: re-add dereference to fix DMA transfers

bcm2835_smi_dev: Fix handling of word-odd lengths

The read and write functions did not use the correct pointer offset
when dealing with an odd number of bytes after a DMA transfer. Also,
only handle the remaining odd bytes if the DMA transfer completed
successfully.

Submitted-by: @madimario (GitHub)
Signed-off-by: Phil Elwell <phil@raspberrypi.com>

misc: bcm2835_smi: Use proper enum types for dma_{,un}map_single()

Clang warns:

  drivers/misc/bcm2835_smi.c:692:4: warning: implicit conversion from enumeration type 'enum dma_transfer_direction' to different enumeration type 'enum dma_data_direction' [-Wenum-conversion]
                          DMA_MEM_TO_DEV);
                          ^~~~~~~~~~~~~~~
  ./include/linux/dma-mapping.h:406:66: note: expanded from macro 'dma_map_single'
  #define dma_map_single(d, a, s, r) dma_map_single_attrs(d, a, s, r, 0)
                                     ~~~~~~~~~~~~~~~~~~~~          ^
  drivers/misc/bcm2835_smi.c:705:35: warning: implicit conversion from enumeration type 'enum dma_transfer_direction' to different enumeration type 'enum dma_data_direction' [-Wenum-conversion]
                          (inst->dev, phy_addr, n_bytes, DMA_MEM_TO_DEV);
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
  ./include/linux/dma-mapping.h:407:70: note: expanded from macro 'dma_unmap_single'
  #define dma_unmap_single(d, a, s, r) dma_unmap_single_attrs(d, a, s, r, 0)
                                       ~~~~~~~~~~~~~~~~~~~~~~          ^
  drivers/misc/bcm2835_smi.c:751:12: warning: implicit conversion from enumeration type 'enum dma_transfer_direction' to different enumeration type 'enum dma_data_direction' [-Wenum-conversion]
                                                       DMA_DEV_TO_MEM);
                                                       ^~~~~~~~~~~~~~~
  ./include/linux/dma-mapping.h:406:66: note: expanded from macro 'dma_map_single'
  #define dma_map_single(d, a, s, r) dma_map_single_attrs(d, a, s, r, 0)
                                     ~~~~~~~~~~~~~~~~~~~~          ^
  drivers/misc/bcm2835_smi.c:761:50: warning: implicit conversion from enumeration type 'enum dma_transfer_direction' to different enumeration type 'enum dma_data_direction' [-Wenum-conversion]
                  dma_unmap_single(inst->dev, phy_addr, n_bytes, DMA_DEV_TO_MEM);
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
  ./include/linux/dma-mapping.h:407:70: note: expanded from macro 'dma_unmap_single'
  #define dma_unmap_single(d, a, s, r) dma_unmap_single_attrs(d, a, s, r, 0)
                                       ~~~~~~~~~~~~~~~~~~~~~~          ^
  4 warnings generated.

Use the proper enumerated type to clear up the warning. There is not
actually a bug here because the enumerated types have the same integer
value:

DMA_MEM_TO_DEV = DMA_TO_DEVICE = 1
DMA_DEV_TO_MEM = DMA_FROM_DEVICE = 2

Fixes: 93254d0 ("Add SMI driver")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>

bcm2835-smi: Use phys addresses for slave DMA config

Contrary to what struct snd_dmaengine_dai_dma_data suggests, the
configuration of addresses of DMA slave interfaces should be done in
CPU physical addresses.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
  • Loading branch information
Wren6991 authored and popcornmix committed Feb 19, 2024
1 parent 5c60c43 commit b5ec35a
Show file tree
Hide file tree
Showing 9 changed files with 1,837 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Documentation/devicetree/bindings/misc/brcm,bcm2835-smi-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
* Broadcom BCM2835 SMI character device driver.

SMI or secondary memory interface is a peripheral specific to certain Broadcom
SOCs, and is helpful for talking to things like parallel-interface displays
and NAND flashes (in fact, most things with a parallel register interface).

This driver adds a character device which provides a user-space interface to
an instance of the SMI driver.

Required properties:
- compatible: "brcm,bcm2835-smi-dev"
- smi_handle: a phandle to the smi node.

Optional properties:
- None.


48 changes: 48 additions & 0 deletions Documentation/devicetree/bindings/misc/brcm,bcm2835-smi.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
* Broadcom BCM2835 SMI driver.

SMI or secondary memory interface is a peripheral specific to certain Broadcom
SOCs, and is helpful for talking to things like parallel-interface displays
and NAND flashes (in fact, most things with a parallel register interface).

Required properties:
- compatible: "brcm,bcm2835-smi"
- reg: Should contain location and length of SMI registers and SMI clkman regs
- interrupts: *the* SMI interrupt.
- pinctrl-names: should be "default".
- pinctrl-0: the phandle of the gpio pin node.
- brcm,smi-clock-source: the clock source for clkman
- brcm,smi-clock-divisor: the integer clock divisor for clkman
- dmas: the dma controller phandle and the DREQ number (4 on a 2835)
- dma-names: the name used by the driver to request its channel.
Should be "rx-tx".

Optional properties:
- None.

Examples:

8 data pin configuration:

smi: smi@7e600000 {
compatible = "brcm,bcm2835-smi";
reg = <0x7e600000 0x44>, <0x7e1010b0 0x8>;
interrupts = <2 16>;
pinctrl-names = "default";
pinctrl-0 = <&smi_pins>;
brcm,smi-clock-source = <6>;
brcm,smi-clock-divisor = <4>;
dmas = <&dma 4>;
dma-names = "rx-tx";

status = "okay";
};

smi_pins: smi_pins {
brcm,pins = <2 3 4 5 6 7 8 9 10 11 12 13 14 15>;
/* Alt 1: SMI */
brcm,function = <5 5 5 5 5 5 5 5 5 5 5 5 5 5>;
/* /CS, /WE and /OE are pulled high, as they are
generally active low signals */
brcm,pull = <2 2 2 2 2 2 0 0 0 0 0 0 0 0>;
};

9 changes: 9 additions & 0 deletions drivers/char/broadcom/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,12 @@ config BCM2835_DEVGPIOMEM
Provides users with root-free access to the GPIO registers
on the 2835. Calling mmap(/dev/gpiomem) will map the GPIO
register page to the user's pointer.

config BCM2835_SMI_DEV
tristate "Character device driver for BCM2835 Secondary Memory Interface"
depends on BCM2835_SMI
default m
help
This driver provides a character device interface (ioctl + read/write) to
Broadcom's Secondary Memory interface. The low-level functionality is provided
by the SMI driver itself.
1 change: 1 addition & 0 deletions drivers/char/broadcom/Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
obj-$(CONFIG_BCM2708_VCMEM) += vc_mem.o
obj-$(CONFIG_BCM2835_DEVGPIOMEM)+= bcm2835-gpiomem.o
obj-$(CONFIG_BCM2835_SMI_DEV) += bcm2835_smi_dev.o

0 comments on commit b5ec35a

Please sign in to comment.