@@ -82,6 +82,13 @@ static struct armdsp_trgbuf *trgbuf;
8282#define MDCTL_ENABLE 0x03
8383#define MDCTL_LRESET (1<<8)
8484
85+ /*
86+ * for these, addr must be in the range IO_PHYS..(IO_PHYS+IO_SIZE)
87+ * which is 0x01c00000 and 0x02000000
88+ * or modules "EDMA3 CC" to "McBSP1 FIFO Data"
89+ *
90+ * outside this range, must use ioremap/iounmap
91+ */
8592#define armdsp_readphys (addr ) (readl(IO_ADDRESS(addr)))
8693#define armdsp_writephys (val ,addr ) (writel(val,IO_ADDRESS(addr)))
8794
@@ -168,6 +175,9 @@ armdsp_ioctl (struct inode *inode, struct file *filp,
168175 unsigned int minor = iminor (filp -> f_path .dentry -> d_inode );
169176 int err = 0 ;
170177 uint32_t val ;
178+ struct armdsp_physio physarg ;
179+ void __user * argp = (void __user * )arg ;
180+ uint32_t __iomem * iop ;
171181
172182 switch (cmd ) {
173183 case ARMDSP_IOCSTOP :
@@ -213,6 +223,39 @@ armdsp_ioctl (struct inode *inode, struct file *filp,
213223 flush_cache_all ();
214224 break ;
215225
226+ case ARMDSP_IOCREADP :
227+ if (copy_from_user (& physarg , argp , sizeof physarg )) {
228+ err = - EFAULT ;
229+ break ;
230+ }
231+ iop = ioremap (physarg .physaddr , sizeof * iop );
232+ if (! iop ) {
233+ err = - EFAULT ;
234+ break ;
235+ }
236+ physarg .val = * iop ;
237+ iounmap (iop );
238+
239+ if (copy_to_user (argp , & physarg , sizeof physarg )) {
240+ err = - EFAULT ;
241+ break ;
242+ }
243+ break ;
244+
245+ case ARMDSP_IOCWRITEP :
246+ if (copy_from_user (& physarg , argp , sizeof physarg )) {
247+ err = - EFAULT ;
248+ break ;
249+ }
250+ iop = ioremap (physarg .physaddr , sizeof * iop );
251+ if (! iop ) {
252+ err = - EFAULT ;
253+ break ;
254+ }
255+ * iop = physarg .val ;
256+ iounmap (iop );
257+ break ;
258+
216259 default :
217260 err = - ENOTTY ;
218261 break ;
@@ -275,68 +318,6 @@ armdsp_irq (int irq, void *dev_id)
275318
276319static int armdsp_need_cdev_del ;
277320
278- static void
279- gpio_test (void )
280- {
281- uint32_t mask5 , mask6 , mask_other ;
282- uint32_t val ;
283-
284- printk ("\n\ngpio test\n" );
285-
286- printk ("pinmux %x = %x\n" , SYSCFG0_PINMUX13 ,
287- armdsp_readphys (SYSCFG0_PINMUX13 ));
288-
289- val = armdsp_readphys (SYSCFG0_PINMUX13 );
290- val &= ~0xffff ;
291- val |= 0x8888 ;
292- armdsp_writephys (val , SYSCFG0_PINMUX13 );
293-
294- printk ("pinmux %x = %x\n" , SYSCFG0_PINMUX13 ,
295- armdsp_readphys (SYSCFG0_PINMUX13 ));
296-
297-
298- mask5 = 1 << 12 ;
299- mask6 = 1 << 13 ;
300- mask_other = (1 << 11 )|(1 << 10 )|(1 << 9 )|(1 << 8 );
301- printk ("dir67 %x\n" , armdsp_readphys (GPIO_DIR67 ));
302-
303- val = armdsp_readphys (GPIO_DIR67 );
304- val &= ~(mask5 | mask6 | mask_other );
305- armdsp_writephys (val , GPIO_DIR67 );
306-
307- printk ("dir67 %x\n" , armdsp_readphys (GPIO_DIR67 ));
308-
309- printk ("out67 %x\n" , armdsp_readphys (GPIO_OUT_DATA67 ));
310-
311- val = armdsp_readphys (GPIO_OUT_DATA67 );
312- if (1 ) {
313- val |= mask5 | mask6 ;
314- } else {
315- val &= ~(mask5 | mask6 );
316- }
317- armdsp_writephys (val , GPIO_OUT_DATA67 );
318- printk ("out67 %x\n" , armdsp_readphys (GPIO_OUT_DATA67 ));
319-
320-
321- val = armdsp_readphys (SYSCFG0_PINMUX11 );
322- val &= ~0xffffff00 ;
323- val |= 0x88888800 ;
324- armdsp_writephys (val , SYSCFG0_PINMUX11 );
325-
326- val = armdsp_readphys (SYSCFG0_PINMUX12 );
327- val &= ~0x0000ffff ;
328- val |= 0x00008888 ;
329- armdsp_writephys (val , SYSCFG0_PINMUX12 );
330-
331- val = armdsp_readphys (SYSCFG0_PINMUX13 );
332- val &= ~0xffffff00 ;
333- val |= 0x88888800 ;
334- armdsp_writephys (val , SYSCFG0_PINMUX13 );
335-
336- }
337-
338-
339-
340321static int __init
341322armdsp_init (void )
342323{
@@ -385,11 +366,6 @@ armdsp_init (void)
385366 dp -> have_irq = 1 ;
386367 }
387368
388-
389- printk ("pinmux %x = %x\n" , SYSCFG0_PINMUX13 , readl (SYSCFG0_PINMUX13 ));
390-
391- gpio_test ();
392-
393369 return (0 );
394370
395371cleanup :
0 commit comments