31 #include <asm/types.h>
36 #include "../../lms2012/source/lms2012.h"
37 #include "../../lms2012/source/am1808.h"
40 #define MODULE_NAME "power_module"
41 #define DEVICE1_NAME POWER_DEVICE
43 static int ModuleInit(
void);
44 static void ModuleExit(
void);
48 #include <linux/kernel.h>
51 #include <linux/sched.h>
55 #include <linux/hrtimer.h>
58 #include <linux/hrtimer.h>
60 #include <linux/init.h>
61 #include <linux/uaccess.h>
62 #include <linux/debugfs.h>
64 #include <linux/ioport.h>
67 #include <linux/module.h>
68 #include <linux/miscdevice.h>
69 #include <asm/uaccess.h>
144 [
FINAL] = FINAL_PowerPin,
145 [
FINALB] = FINALB_PowerPin,
146 [
EP2] = EP2_PowerPin,
152 static void __iomem *GpioBase;
173 printk(
" GP%d_%-2d 0x%08X and 0x%08X or 0x%08X\n",(Pin >> 4),(Pin & 0x0F),(
u32)Reg,
MuxRegMap[Tmp].Mask,
MuxRegMap[Tmp].Mode);
178 printk(
"* GP%d_%-2d ********* ERROR not found *********\n",(Pin >> 4),(Pin & 0x0F));
194 memcpy(PowerPin,pPowerPin[
Hw],
sizeof(EP2_PowerPin));
195 if (memcmp((
const void*)PowerPin,(
const void*)pPowerPin[Hw],
sizeof(EP2_PowerPin)) != 0)
202 if (PowerPin[Pin].Pin >= 0)
204 PowerPin[Pin].
pGpio = (
struct gpio_controller *__iomem)(GpioBase + ((PowerPin[Pin].Pin >> 5) * 0x28) + 0x10);
205 PowerPin[Pin].
Mask = (1 << (PowerPin[Pin].
Pin & 0x1F));
217 (*PowerPin[P_EN].pGpio).set_data = PowerPin[P_EN].Mask;\
218 (*PowerPin[P_EN].pGpio).dir &= ~PowerPin[P_EN].Mask;\
219 (*PowerPin[PENON].pGpio).set_data = PowerPin[PENON].Mask;\
220 (*PowerPin[PENON].pGpio).dir &= ~PowerPin[PENON].Mask;\
225 (*PowerPin[SW_RECHARGE].pGpio).dir |= PowerPin[SW_RECHARGE].Mask;\
229 #define ACCURead ((*PowerPin[SW_RECHARGE].pGpio).in_data & PowerPin[SW_RECHARGE].Mask)
233 (*PowerPin[TESTPIN].pGpio).set_data = PowerPin[TESTPIN].Mask;\
234 (*PowerPin[TESTPIN].pGpio).dir &= ~PowerPin[TESTPIN].Mask;\
238 (*PowerPin[TESTPIN].pGpio).clr_data = PowerPin[TESTPIN].Mask;\
239 (*PowerPin[TESTPIN].pGpio).dir &= ~PowerPin[TESTPIN].Mask;\
245 static int Device1Ioctl(
struct inode *pNode,
struct file *File,
unsigned int Request,
unsigned long Pointer)
253 static ssize_t Device1Write(
struct file *File,
const char *
Buffer,
size_t Count,loff_t *Data)
260 copy_from_user(Buf,Buffer,Count);
277 static ssize_t Device1Read(
struct file *File,
char *Buffer,
size_t Count,loff_t *Offset)
291 Lng =
snprintf(Buffer,Count,
"%c\r",Accu);
297 static const struct file_operations Device1Entries =
299 .owner = THIS_MODULE,
301 .write = Device1Write,
302 .ioctl = Device1Ioctl
306 static struct miscdevice Device1 =
314 static int Device1Init(
void)
318 Result = misc_register(&Device1);
334 static void Device1Exit(
void)
336 misc_deregister(&Device1);
350 static int ModuleInit(
void)
367 if (request_mem_region(DA8XX_GPIO_BASE,0xD8,
MODULE_NAME) >= 0)
369 GpioBase = (
void*)ioremap(DA8XX_GPIO_BASE,0xD8);
370 if (GpioBase !=
NULL)
389 static void ModuleExit(
void)
MODULE_SUPPORTED_DEVICE(DEVICE1_NAME)
#define EP2
Schematics revision D.
#define FINAL
Final prototype.
INPIN PowerPin[POWER_PINS]
#define FINALB
Schematics revision B and C.
module_param(HwId, charp, 0)
MODULE_AUTHOR("The LEGO Group")
MODULE_DESCRIPTION(MODULE_NAME)
#define PLATFORM_END
Newest supported hardware (newer versions will use this)
#define PLATFORM_START
Oldest supported hardware (older versions will use this)