Commit 636a8f86 authored by Andrey Filippov's avatar Andrey Filippov

added ioremap and a static pointer for the use of writel() and readl()

parent effa97e5
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
...@@ -40,9 +40,10 @@ class X393ExportC(object): ...@@ -40,9 +40,10 @@ class X393ExportC(object):
DRY_MODE = True # True DRY_MODE = True # True
DEBUG_MODE = 1 DEBUG_MODE = 1
MAXI0_BASE = 0x40000000 MAXI0_BASE = 0x40000000
verbose=1 MAXI0_RANGE = 0x00003000
func_decl=None verbose = 1
func_def= None func_decl = None
func_def = None
typedefs = None typedefs = None
gen_dir = "generated" gen_dir = "generated"
typdefs_file = "x393_types.h" # typdef for hardware registers typdefs_file = "x393_types.h" # typdef for hardware registers
...@@ -144,6 +145,9 @@ class X393ExportC(object): ...@@ -144,6 +145,9 @@ class X393ExportC(object):
# Includes section # Includes section
txt = '\n#include <linux/io.h>\n' txt = '\n#include <linux/io.h>\n'
txt += '#include "x393.h"\n\n' txt += '#include "x393.h"\n\n'
txt += 'static void __iomem mmio_ptr;\n\n'
txt += '// init_mmio_ptr() should be called once before using any of the other defined functions\n\n'
txt += 'int init_mmio_ptr(void) {mmio_ptr = ioremap(0x%08x, 0x%08x); if (!mmio_ptr) return -1; else return 0;}\n'%(self.MAXI0_BASE,self.MAXI0_RANGE)
for d in ld: for d in ld:
fd=self.expand_define_maxi0(d, mode = "func_def",frmt_spcs = None) fd=self.expand_define_maxi0(d, mode = "func_def",frmt_spcs = None)
...@@ -1278,8 +1282,7 @@ class X393ExportC(object): ...@@ -1278,8 +1282,7 @@ class X393ExportC(object):
else: else:
td='d' td='d'
# s+='{ %s d; %s = readl(0x%08x'%(data_type, td,address) s+='{ %s d; %s = readl(mmio_ptr + '%(data_type, td)
s+='{ %s d; %s = readl((void*) '%(data_type, td)
if address_inc: if address_inc:
s+='(0x%08x'%(address) s+='(0x%08x'%(address)
if multivar: if multivar:
...@@ -1288,10 +1291,8 @@ class X393ExportC(object): ...@@ -1288,10 +1291,8 @@ class X393ExportC(object):
else: else:
s+=' + 0x%x * %s'%(address_inc, arg) s+=' + 0x%x * %s'%(address_inc, arg)
s += ')' s += ')'
# s+='return (%s) readl(0x%08x + 0x%x * %s)'%(data_type, address, address_inc, arg)
else: else:
s+='0x%08x'%(address) s+='0x%08x'%(address)
# s+='return (%s) readl(0x%08x)'%(data_type, address)
s+='); return d; }' s+='); return d; }'
else: else:
s += ';' s += ';'
...@@ -1336,7 +1337,7 @@ class X393ExportC(object): ...@@ -1336,7 +1337,7 @@ class X393ExportC(object):
td = 'd.%s'%(frmt_spcs['data32']) td = 'd.%s'%(frmt_spcs['data32'])
else: else:
td='d' td='d'
s+='{writel(%s, (void *) '%(td) s+='{writel(%s, mmio_ptr + '%(td)
if address_inc: if address_inc:
s+='(0x%08x'%(address) s+='(0x%08x'%(address)
if multivar: if multivar:
...@@ -1382,7 +1383,7 @@ class X393ExportC(object): ...@@ -1382,7 +1383,7 @@ class X393ExportC(object):
s = self.str_tab_stop(s,stops[2]) s = self.str_tab_stop(s,stops[2])
if isDefine: if isDefine:
# s+='{' # s+='{'
s+='{writel(0, (void *) ' s+='{writel(0, mmio_ptr + '
if address_inc: if address_inc:
s+='(0x%08x'%(address) s+='(0x%08x'%(address)
if multivar: if multivar:
...@@ -2379,7 +2380,7 @@ class X393ExportC(object): ...@@ -2379,7 +2380,7 @@ class X393ExportC(object):
members = {} # name:tuple of (start, len) members = {} # name:tuple of (start, len)
for ns,struct in enumerate(data): for ns,struct in enumerate(data):
lines=self.get_pad32(struct, wlen=32, name=name, padLast=frmt_spcs['lastPad']) lines=self.get_pad32(struct, wlen=32, name=name, padLast=frmt_spcs['lastPad'])
lines.reverse() # lines.reverse()
#nameMembers #nameMembers
if isUnion: if isUnion:
s += " struct {\n" s += " struct {\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment