/* SPDX-License-Identifier: GPL-2.0-only */ /* * cb710/cb710.h * * Copyright by Michał Mirosław, 2008-2009 */ #ifndef LINUX_CB710_DRIVER_H #define LINUX_CB710_DRIVER_H #include <linux/io.h> #include <linux/interrupt.h> #include <linux/spinlock.h> #include <linux/pci.h> #include <linux/platform_device.h> #include <linux/mmc/host.h> struct cb710_slot; cb710_irq_handler_t; /* per-virtual-slot structure */ struct cb710_slot { … }; /* per-device structure */ struct cb710_chip { … }; /* NOTE: cb710_chip.slots is modified only during device init/exit and * they are all serialized wrt themselves */ /* cb710_chip.slot_mask values */ #define CB710_SLOT_MMC … #define CB710_SLOT_MS … #define CB710_SLOT_SM … /* slot port accessors - so the logic is more clear in the code */ #define CB710_PORT_ACCESSORS(t) … CB710_PORT_ACCESSORS(…) CB710_PORT_ACCESSORS(…) CB710_PORT_ACCESSORS(…) void cb710_pci_update_config_reg(struct pci_dev *pdev, int reg, uint32_t and, uint32_t xor); void cb710_set_irq_handler(struct cb710_slot *slot, cb710_irq_handler_t handler); /* some device struct walking */ static inline struct cb710_slot *cb710_pdev_to_slot( struct platform_device *pdev) { … } static inline struct cb710_chip *cb710_slot_to_chip(struct cb710_slot *slot) { … } static inline struct device *cb710_slot_dev(struct cb710_slot *slot) { … } static inline struct device *cb710_chip_dev(struct cb710_chip *chip) { … } /* debugging aids */ #ifdef CONFIG_CB710_DEBUG void cb710_dump_regs(struct cb710_chip *chip, unsigned dump); #else #define cb710_dump_regs … #endif #define CB710_DUMP_REGS_MMC … #define CB710_DUMP_REGS_MS … #define CB710_DUMP_REGS_SM … #define CB710_DUMP_REGS_ALL … #define CB710_DUMP_REGS_MASK … #define CB710_DUMP_ACCESS_8 … #define CB710_DUMP_ACCESS_16 … #define CB710_DUMP_ACCESS_32 … #define CB710_DUMP_ACCESS_ALL … #define CB710_DUMP_ACCESS_MASK … #endif /* LINUX_CB710_DRIVER_H */ /* * cb710/sgbuf2.h * * Copyright by Michał Mirosław, 2008-2009 */ #ifndef LINUX_CB710_SG_H #define LINUX_CB710_SG_H #include <linux/highmem.h> #include <linux/scatterlist.h> /* * 32-bit PIO mapping sg iterator * * Hides scatterlist access issues - fragment boundaries, alignment, page * mapping - for drivers using 32-bit-word-at-a-time-PIO (ie. PCI devices * without DMA support). * * Best-case reading (transfer from device): * sg_miter_start(, SG_MITER_TO_SG); * cb710_sg_dwiter_write_from_io(); * sg_miter_stop(); * * Best-case writing (transfer to device): * sg_miter_start(, SG_MITER_FROM_SG); * cb710_sg_dwiter_read_to_io(); * sg_miter_stop(); */ uint32_t cb710_sg_dwiter_read_next_block(struct sg_mapping_iter *miter); void cb710_sg_dwiter_write_next_block(struct sg_mapping_iter *miter, uint32_t data); /** * cb710_sg_dwiter_write_from_io - transfer data to mapped buffer from 32-bit IO port * @miter: sg mapping iter * @port: PIO port - IO or MMIO address * @count: number of 32-bit words to transfer * * Description: * Reads @count 32-bit words from register @port and stores it in * buffer iterated by @miter. Data that would overflow the buffer * is silently ignored. Iterator is advanced by 4*@count bytes * or to the buffer's end whichever is closer. * * Context: * IRQ disabled if the SG_MITER_ATOMIC is set. Don't care otherwise. */ static inline void cb710_sg_dwiter_write_from_io(struct sg_mapping_iter *miter, void __iomem *port, size_t count) { … } /** * cb710_sg_dwiter_read_to_io - transfer data to 32-bit IO port from mapped buffer * @miter: sg mapping iter * @port: PIO port - IO or MMIO address * @count: number of 32-bit words to transfer * * Description: * Writes @count 32-bit words to register @port from buffer iterated * through @miter. If buffer ends before @count words are written * missing data is replaced by zeroes. @miter is advanced by 4*@count * bytes or to the buffer's end whichever is closer. * * Context: * IRQ disabled if the SG_MITER_ATOMIC is set. Don't care otherwise. */ static inline void cb710_sg_dwiter_read_to_io(struct sg_mapping_iter *miter, void __iomem *port, size_t count) { … } #endif /* LINUX_CB710_SG_H */