<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi Anatolij,<div>thank you so much for you answer… monday i’ll test… </div><div>i answer you just to complete the information:</div><div>we are using an mpc5200b and the details for that reg located at: 0x10020000 are:</div><div><br></div><div><div>Chip select 4 specification:</div><div>Lp_cs4</div><div>bus size: 8 bit</div><div>bus control: 2 wait state R/W ACK disabled</div><div>size allocated: 4 KByte</div><div><br></div><div>Our Register 8 bit LP_cs4 (we want to write)</div><div><br></div><div>cs4 offset: 0x001</div><div><br></div><div>Thank you again..</div><div><br></div><div>Lorenzo</div><div><br></div><div><div>On 16/nov/2013, at 03:29 PM, Anatolij Gustschin <<a href="mailto:agust@denx.de">agust@denx.de</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Hi Lorenzo,<br><br>see my comments below.<br><br>On Fri, 15 Nov 2013 17:27:30 +0100<br>neorf3k <<a href="mailto:neorf3k@gmail.com">neorf3k@gmail.com</a>> wrote:<br><br><blockquote type="cite">Hello again, I’ve tried this code, but we are not able to<br>change cs4 reg value… what could be?<br><br>—<br><br>#define MALab_DEVICE_NAME<span class="Apple-tab-span" style="white-space: pre;">   </span>"MALab"<br>#define MPC5xxx_MM_CS4_START<span class="Apple-tab-span" style="white-space: pre;">   </span>(MBAR_BASE + 0x0024)<br>#define MPC5xxx_MM_CS4_STOP<span class="Apple-tab-span" style="white-space: pre;"> </span>(MBAR_BASE + 0x0028)<br>#define MPC5xxx_MM_IPBI<span class="Apple-tab-span" style="white-space: pre;">     </span><span class="Apple-converted-space"> </span>(MBAR_BASE + 0x0054)<br><br>#define MALab_MM_START<span class="Apple-tab-span" style="white-space: pre;">     </span><span class="Apple-converted-space"> </span>0x10020000U<br>#define MALab_MM_END<span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-converted-space"> </span>0x10020FFFU<br></blockquote><br>Please change MALab_MM_END to 0x10030000U.<br><br><blockquote type="cite">#define MALab_MM_SIZE<span class="Apple-tab-span" style="white-space: pre;">      </span><span class="Apple-converted-space"> </span>0x00001000U<br><br>int init_module(void) { ...<br>   u16 cs4_start_value;<br>   u16 cs4_stop_value;<br>   u32 cs4_enable_value;<br><br>   u8 rvoice_ioaddr_value;<br><br><br>   // reserve a page of memory for our hardware /proc/iomem<br>   if ( check_region(MALab_MM_START,MALab_MM_SIZE) ) {<br>       printk (KERN_ALERT "LED init_module: memory already in use\n");<br>       return -EBUSY;<br>   }<br><br><br>   request_mem_region(MALab_MM_START,MALab_MM_SIZE,MALab_DEVICE_NAME);<br><br><br>   void __iomem *cs0_reg   = ioremap ((volatile unsigned long)(MBAR_BASE + 0x0300), 4);<br>   void __iomem *cs3_reg   = ioremap ((volatile unsigned long)(MBAR_BASE + 0x030C), 4);<br><br>   void __iomem *ipbi_cr = ioremap ((volatile unsigned long)(MPC5xxx_MM_IPBI), 4);<br>   void __iomem *cs4_start  = ioremap ((volatile unsigned long)(MPC5xxx_MM_CS4_START + 2), 2);<br>   void __iomem *cs4_stop   = ioremap ((volatile unsigned long)(MPC5xxx_MM_CS4_STOP + 2), 2);<br><br>   void __iomem *cs4_enable   = ioremap ((volatile unsigned long)(MBAR_BASE + 0x0310), 4);<br>   void __iomem *cs_ctrl_reg   = ioremap ((volatile unsigned long)(MBAR_BASE + 0x0318), 4);<br></blockquote><br><br>this might work, but this is not how ioremap() supposed to be used.<br>The mapping is done in 4k-page granularity, so it would be better<br>to just map the internal register range my one ioremap() call, i.e.<br><br>   reg_base = ioremap(MBAR_BASE, 0x400);<br><br>and then to calculate the register offsets, i.e.<br><br>  cs0_reg = reg_base + 0x0300;<br>  cs0_reg = reg_base + 0x030C;<br>  ...<br>  ipbi_cr = reg_base + 0x0054;<br>  cs4_start = reg_base + 0x0026;<br>  cs4_stop = reg_base + 0x002a;<br>  ...<br><br>For FPGA mapping you need a separate ioremap() call of course.<br><br><blockquote type="cite">   void __iomem *rvoice_ioaddr   = ioremap ((volatile unsigned long)(MALab_MM_START), MALab_MM_SIZE);<br><br>   //disable CSO<br><br>   out_be32(cs0_reg, 0x0004ed00);<br><br><br>   //disable CS3<br><br>   out_be32(cs3_reg, 0x0002cf00);<br><br>   // enable LocalBus chip select CS4<br>   out_be32(ipbi_cr, 0x00290001);<br></blockquote><br>The comment and the code doesn't match here, the code disables<br>CS4 to configure the its range, so the comment is confusing.<br><br><blockquote type="cite">   cs4_start_value=in_be16(cs4_start);<br>   cs4_start_value=MALab_MM_START >>16;<br>   out_be16(cs4_start, cs4_start_value);<br>   cs4_stop_value=in_be16(cs4_stop);<br>   cs4_stop_value=MALab_MM_END >>16;<br>   out_be16(cs4_stop, cs4_stop_value);<br></blockquote><br>Here is the problem. The _minimal_ chip select range _must_<br>be 64 KiB, otherwise the register access can't work. Your<br>current chip select 4 range is less then 1 KiB:<br><br> 0x10020FFF - 0x10020000 = 0xFFF<br><br>Since you right-shift the start and stop values by 16,<br>the chip select start and stop registers are both 0x1002.<br>The resulting chip select address range is 0. Therefore<br>please set MALab_MM_END value to 0x10030000.<br><br>Thanks,<br>Anatolij</div></blockquote></div><br></div></body></html>