~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/cb710.h

Version: ~ [ linux-5.3-rc5 ] ~ [ linux-5.2.9 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.67 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.139 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.189 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.189 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.72 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  *  cb710/cb710.h
  3  *
  4  *  Copyright by Michał Mirosław, 2008-2009
  5  *
  6  * This program is free software; you can redistribute it and/or modify
  7  * it under the terms of the GNU General Public License version 2 as
  8  * published by the Free Software Foundation.
  9  */
 10 #ifndef LINUX_CB710_DRIVER_H
 11 #define LINUX_CB710_DRIVER_H
 12 
 13 #include <linux/io.h>
 14 #include <linux/interrupt.h>
 15 #include <linux/spinlock.h>
 16 #include <linux/pci.h>
 17 #include <linux/platform_device.h>
 18 #include <linux/mmc/host.h>
 19 
 20 struct cb710_slot;
 21 
 22 typedef int (*cb710_irq_handler_t)(struct cb710_slot *);
 23 
 24 /* per-virtual-slot structure */
 25 struct cb710_slot {
 26         struct platform_device  pdev;
 27         void __iomem            *iobase;
 28         cb710_irq_handler_t     irq_handler;
 29 };
 30 
 31 /* per-device structure */
 32 struct cb710_chip {
 33         struct pci_dev          *pdev;
 34         void __iomem            *iobase;
 35         unsigned                platform_id;
 36 #ifdef CONFIG_CB710_DEBUG_ASSUMPTIONS
 37         atomic_t                slot_refs_count;
 38 #endif
 39         unsigned                slot_mask;
 40         unsigned                slots;
 41         spinlock_t              irq_lock;
 42         struct cb710_slot       slot[0];
 43 };
 44 
 45 /* NOTE: cb710_chip.slots is modified only during device init/exit and
 46  * they are all serialized wrt themselves */
 47 
 48 /* cb710_chip.slot_mask values */
 49 #define CB710_SLOT_MMC          1
 50 #define CB710_SLOT_MS           2
 51 #define CB710_SLOT_SM           4
 52 
 53 /* slot port accessors - so the logic is more clear in the code */
 54 #define CB710_PORT_ACCESSORS(t) \
 55 static inline void cb710_write_port_##t(struct cb710_slot *slot,        \
 56         unsigned port, u##t value)                                      \
 57 {                                                                       \
 58         iowrite##t(value, slot->iobase + port);                         \
 59 }                                                                       \
 60                                                                         \
 61 static inline u##t cb710_read_port_##t(struct cb710_slot *slot,         \
 62         unsigned port)                                                  \
 63 {                                                                       \
 64         return ioread##t(slot->iobase + port);                          \
 65 }                                                                       \
 66                                                                         \
 67 static inline void cb710_modify_port_##t(struct cb710_slot *slot,       \
 68         unsigned port, u##t set, u##t clear)                            \
 69 {                                                                       \
 70         iowrite##t(                                                     \
 71                 (ioread##t(slot->iobase + port) & ~clear)|set,          \
 72                 slot->iobase + port);                                   \
 73 }
 74 
 75 CB710_PORT_ACCESSORS(8)
 76 CB710_PORT_ACCESSORS(16)
 77 CB710_PORT_ACCESSORS(32)
 78 
 79 void cb710_pci_update_config_reg(struct pci_dev *pdev,
 80         int reg, uint32_t and, uint32_t xor);
 81 void cb710_set_irq_handler(struct cb710_slot *slot,
 82         cb710_irq_handler_t handler);
 83 
 84 /* some device struct walking */
 85 
 86 static inline struct cb710_slot *cb710_pdev_to_slot(
 87         struct platform_device *pdev)
 88 {
 89         return container_of(pdev, struct cb710_slot, pdev);
 90 }
 91 
 92 static inline struct cb710_chip *cb710_slot_to_chip(struct cb710_slot *slot)
 93 {
 94         return dev_get_drvdata(slot->pdev.dev.parent);
 95 }
 96 
 97 static inline struct device *cb710_slot_dev(struct cb710_slot *slot)
 98 {
 99         return &slot->pdev.dev;
100 }
101 
102 static inline struct device *cb710_chip_dev(struct cb710_chip *chip)
103 {
104         return &chip->pdev->dev;
105 }
106 
107 /* debugging aids */
108 
109 #ifdef CONFIG_CB710_DEBUG
110 void cb710_dump_regs(struct cb710_chip *chip, unsigned dump);
111 #else
112 #define cb710_dump_regs(c, d) do {} while (0)
113 #endif
114 
115 #define CB710_DUMP_REGS_MMC     0x0F
116 #define CB710_DUMP_REGS_MS      0x30
117 #define CB710_DUMP_REGS_SM      0xC0
118 #define CB710_DUMP_REGS_ALL     0xFF
119 #define CB710_DUMP_REGS_MASK    0xFF
120 
121 #define CB710_DUMP_ACCESS_8     0x100
122 #define CB710_DUMP_ACCESS_16    0x200
123 #define CB710_DUMP_ACCESS_32    0x400
124 #define CB710_DUMP_ACCESS_ALL   0x700
125 #define CB710_DUMP_ACCESS_MASK  0x700
126 
127 #endif /* LINUX_CB710_DRIVER_H */
128 /*
129  *  cb710/sgbuf2.h
130  *
131  *  Copyright by Michał Mirosław, 2008-2009
132  *
133  * This program is free software; you can redistribute it and/or modify
134  * it under the terms of the GNU General Public License version 2 as
135  * published by the Free Software Foundation.
136  */
137 #ifndef LINUX_CB710_SG_H
138 #define LINUX_CB710_SG_H
139 
140 #include <linux/highmem.h>
141 #include <linux/scatterlist.h>
142 
143 /*
144  * 32-bit PIO mapping sg iterator
145  *
146  * Hides scatterlist access issues - fragment boundaries, alignment, page
147  * mapping - for drivers using 32-bit-word-at-a-time-PIO (ie. PCI devices
148  * without DMA support).
149  *
150  * Best-case reading (transfer from device):
151  *   sg_miter_start(, SG_MITER_TO_SG);
152  *   cb710_sg_dwiter_write_from_io();
153  *   sg_miter_stop();
154  *
155  * Best-case writing (transfer to device):
156  *   sg_miter_start(, SG_MITER_FROM_SG);
157  *   cb710_sg_dwiter_read_to_io();
158  *   sg_miter_stop();
159  */
160 
161 uint32_t cb710_sg_dwiter_read_next_block(struct sg_mapping_iter *miter);
162 void cb710_sg_dwiter_write_next_block(struct sg_mapping_iter *miter, uint32_t data);
163 
164 /**
165  * cb710_sg_dwiter_write_from_io - transfer data to mapped buffer from 32-bit IO port
166  * @miter: sg mapping iter
167  * @port: PIO port - IO or MMIO address
168  * @count: number of 32-bit words to transfer
169  *
170  * Description:
171  *   Reads @count 32-bit words from register @port and stores it in
172  *   buffer iterated by @miter.  Data that would overflow the buffer
173  *   is silently ignored.  Iterator is advanced by 4*@count bytes
174  *   or to the buffer's end whichever is closer.
175  *
176  * Context:
177  *   IRQ disabled if the SG_MITER_ATOMIC is set.  Don't care otherwise.
178  */
179 static inline void cb710_sg_dwiter_write_from_io(struct sg_mapping_iter *miter,
180         void __iomem *port, size_t count)
181 {
182         while (count-- > 0)
183                 cb710_sg_dwiter_write_next_block(miter, ioread32(port));
184 }
185 
186 /**
187  * cb710_sg_dwiter_read_to_io - transfer data to 32-bit IO port from mapped buffer
188  * @miter: sg mapping iter
189  * @port: PIO port - IO or MMIO address
190  * @count: number of 32-bit words to transfer
191  *
192  * Description:
193  *   Writes @count 32-bit words to register @port from buffer iterated
194  *   through @miter.  If buffer ends before @count words are written
195  *   missing data is replaced by zeroes. @miter is advanced by 4*@count
196  *   bytes or to the buffer's end whichever is closer.
197  *
198  * Context:
199  *   IRQ disabled if the SG_MITER_ATOMIC is set.  Don't care otherwise.
200  */
201 static inline void cb710_sg_dwiter_read_to_io(struct sg_mapping_iter *miter,
202         void __iomem *port, size_t count)
203 {
204         while (count-- > 0)
205                 iowrite32(cb710_sg_dwiter_read_next_block(miter), port);
206 }
207 
208 #endif /* LINUX_CB710_SG_H */
209 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp