コード例 #1
0
void rtc_cmos_write(unsigned char val, unsigned char addr)
{
	lock_cmos_prefix(addr);
	outb(addr, RTC_PORT(0));
	outb(val, RTC_PORT(1));
	lock_cmos_suffix(addr);
}
コード例 #2
0
ファイル: setup.c プロジェクト: iPodLinux/linux-2.6.7-ipod
static void __init
reserve_std_resources(void)
{
	static struct resource standard_io_resources[] = {
		{ "rtc", -1, -1 },
        	{ "dma1", 0x00, 0x1f },
        	{ "pic1", 0x20, 0x3f },
        	{ "timer", 0x40, 0x5f },
        	{ "keyboard", 0x60, 0x6f },
        	{ "dma page reg", 0x80, 0x8f },
        	{ "pic2", 0xa0, 0xbf },
        	{ "dma2", 0xc0, 0xdf },
	};

	struct resource *io = &ioport_resource;
	size_t i;

	if (hose_head) {
		struct pci_controller *hose;
		for (hose = hose_head; hose; hose = hose->next)
			if (hose->index == 0) {
				io = hose->io_space;
				break;
			}
	}

	/* Fix up for the Jensen's queer RTC placement.  */
	standard_io_resources[0].start = RTC_PORT(0);
	standard_io_resources[0].end = RTC_PORT(0) + 0x10;

	for (i = 0; i < N(standard_io_resources); ++i)
		request_resource(io, standard_io_resources+i);
}
コード例 #3
0
ファイル: time.c プロジェクト: spacex/kernel-centos5
/* Routines for accessing the CMOS RAM/RTC. */
unsigned char rtc_cmos_read(unsigned char addr)
{
	unsigned char val;
	lock_cmos_prefix(addr);
	outb_p(addr, RTC_PORT(0));
	val = inb_p(RTC_PORT(1));
	lock_cmos_suffix(addr);
	return val;
}
コード例 #4
0
ファイル: rtc.c プロジェクト: 0day-ci/xen
void rtc_init(struct domain *d)
{
    RTCState *s = domain_vrtc(d);

    if ( !has_vrtc(d) )
        return;

    spin_lock_init(&s->lock);

    init_timer(&s->update_timer, rtc_update_timer, s, smp_processor_id());
    init_timer(&s->update_timer2, rtc_update_timer2, s, smp_processor_id());
    init_timer(&s->alarm_timer, rtc_alarm_cb, s, smp_processor_id());

    register_portio_handler(d, RTC_PORT(0), 2, handle_rtc_io);

    rtc_reset(d);

    spin_lock(&s->lock);

    s->hw.cmos_data[RTC_REG_A] = RTC_REF_CLCK_32KHZ | 6; /* ~1kHz */
    s->hw.cmos_data[RTC_REG_B] = RTC_24H;
    s->hw.cmos_data[RTC_REG_C] = 0;
    s->hw.cmos_data[RTC_REG_D] = RTC_VRT;

    s->current_tm = gmtime(get_localtime(d));
    s->start_time = NOW();

    rtc_copy_date(s);

    check_update_timer(s);
    spin_unlock(&s->lock);
}
コード例 #5
0
ファイル: rtc.c プロジェクト: chinnyannieb/empeg-hijack
__initfunc(int rtc_init(void))
{
	unsigned long flags;
#ifdef __alpha__
	unsigned int year, ctrl;
	unsigned long uip_watchdog;
	char *guess = NULL;
#endif
	printk(KERN_INFO "Real Time Clock Driver v%s\n", RTC_VERSION);
	if(request_irq(RTC_IRQ, rtc_interrupt, SA_INTERRUPT, "rtc", NULL))
	{
		/* Yeah right, seeing as irq 8 doesn't even hit the bus. */
		printk(KERN_ERR "rtc: IRQ %d is not free.\n", RTC_IRQ);
		return -EIO;
	}
	misc_register(&rtc_dev);
	/* Check region? Naaah! Just snarf it up. */
	request_region(RTC_PORT(0), RTC_IO_EXTENT, "rtc");
#ifdef __alpha__
	rtc_freq = HZ;
	
	/* Each operating system on an Alpha uses its own epoch.
	   Let's try to guess which one we are using now. */
	
	uip_watchdog = jiffies;
	if (rtc_is_updating() != 0)
		while (jiffies - uip_watchdog < 2*HZ/100)
			barrier();
	
	save_flags(flags);
	cli();
	year = CMOS_READ(RTC_YEAR);
	ctrl = CMOS_READ(RTC_CONTROL);
	restore_flags(flags);
	
	if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
		BCD_TO_BIN(year);       /* This should never happen... */
	
	if (year > 10 && year < 44) {
		epoch = 1980;
		guess = "ARC console";
	} else if (year < 96) {
		epoch = 1952;
		guess = "Digital UNIX";
	}
	if (guess)
		printk("rtc: %s epoch (%lu) detected\n", guess, epoch);
#endif
	init_timer(&rtc_irq_timer);
	rtc_irq_timer.function = rtc_dropped_irq;
	rtc_wait = NULL;
	save_flags(flags);
	cli();
	/* Initialize periodic freq. to CMOS reset default, which is 1024Hz */
	CMOS_WRITE(((CMOS_READ(RTC_FREQ_SELECT) & 0xF0) | 0x06), RTC_FREQ_SELECT);
	restore_flags(flags);
	rtc_freq = 1024;
	return 0;
}
コード例 #6
0
ファイル: fallback_boot.c プロジェクト: 0ida/coreboot
static void set_boot_successful(void)
{
	/* Remember I successfully booted by setting
	 * the initial boot direction
	 * to the direction that I booted.
	 */
	unsigned char index, byte;
	index = inb(RTC_PORT(0)) & 0x80;
	index |= RTC_BOOT_BYTE;
	outb(index, RTC_PORT(0));

	byte = inb(RTC_PORT(1));
	byte &= 0xfe;
	byte |= (byte & (1 << 1)) >> 1;

	/* If we are in normal mode set the boot count to 0 */
	if(byte & 1)
		byte &= 0x0f;
	outb(byte, RTC_PORT(1));
}
コード例 #7
0
static int  __init add_rtc(void)
{
	struct device_node *np;
	struct platform_device *pd;
	struct resource res[2];
	unsigned int num_res = 1;
	int ret;

	memset(&res, 0, sizeof(res));

	np = of_find_compatible_node(NULL, NULL, "pnpPNP,b00");
	if (!np)
		return -ENODEV;

	ret = of_address_to_resource(np, 0, &res[0]);
	of_node_put(np);
	if (ret)
		return ret;

	/*
                                                                   
                                                
  */
	if (res[0].start != RTC_PORT(0))
		return -EINVAL;

	np = of_find_compatible_node(NULL, NULL, "chrp,iic");
	if (!np)
		np = of_find_compatible_node(NULL, NULL, "pnpPNP,000");
	if (np) {
		of_node_put(np);
		/*
                                                            
                                                              
                   
   */
		res[1].start = 8;
		res[1].end = 8;
		res[1].flags = IORESOURCE_IRQ;
		num_res++;
	}

	pd = platform_device_register_simple("rtc_cmos", -1,
					     &res[0], num_res);

	if (IS_ERR(pd))
		return PTR_ERR(pd);

	return 0;
}
コード例 #8
0
ファイル: rtc.c プロジェクト: iPodLinux/linux-2.4.24-ipod
static void __exit rtc_exit (void)
{
	cleanup_sysctl();
	remove_proc_entry ("driver/rtc", NULL);
	misc_deregister(&rtc_dev);

#ifdef __sparc__
	if (rtc_has_irq)
		free_irq (rtc_irq, &rtc_port);
#else
	release_region (RTC_PORT (0), RTC_IO_EXTENT);
#if RTC_IRQ
	if (rtc_has_irq)
		free_irq (RTC_IRQ, NULL);
#endif
#endif /* __sparc__ */
}
コード例 #9
0
ファイル: rtc_cmos_setup.c プロジェクト: human3000/linux-2.6
static int  __init add_rtc(void)
{
	struct device_node *np;
	struct platform_device *pd;
	struct resource res[2];
	int ret;

	memset(&res, 0, sizeof(res));

	np = of_find_compatible_node(NULL, NULL, "pnpPNP,b00");
	if (!np)
		return -ENODEV;

	ret = of_address_to_resource(np, 0, &res[0]);
	of_node_put(np);
	if (ret)
		return ret;

	/*
	 * RTC_PORT(x) is hardcoded in asm/mc146818rtc.h.  Verify that the
	 * address provided by the device node matches.
	 */
	if (res[0].start != RTC_PORT(0))
		return -EINVAL;

	/* Use a fixed interrupt value of 8 since on PPC if we are using this
	 * its off an i8259 which we ensure has interrupt numbers 0..15. */
	res[1].start = 8;
	res[1].end = 8;
	res[1].flags = IORESOURCE_IRQ;

	pd = platform_device_register_simple("rtc_cmos", -1,
					     &res[0], 2);

	if (IS_ERR(pd))
		return PTR_ERR(pd);

	return 0;
}
コード例 #10
0
ファイル: time.c プロジェクト: Blackburn29/PsycoKernel
unsigned long __init maple_get_boot_time(void)
{
	struct rtc_time tm;
	struct device_node *rtcs;

	rtcs = of_find_compatible_node(NULL, "rtc", "pnpPNP,b00");
	if (rtcs) {
		struct resource r;
		if (of_address_to_resource(rtcs, 0, &r)) {
			printk(KERN_EMERG "Maple: Unable to translate RTC"
			       " address\n");
			goto bail;
		}
		if (!(r.flags & IORESOURCE_IO)) {
			printk(KERN_EMERG "Maple: RTC address isn't PIO!\n");
			goto bail;
		}
		maple_rtc_addr = r.start;
		printk(KERN_INFO "Maple: Found RTC at IO 0x%x\n",
		       maple_rtc_addr);
	}
 bail:
	if (maple_rtc_addr == 0) {
		maple_rtc_addr = RTC_PORT(0); 
		printk(KERN_INFO "Maple: No device node for RTC, assuming "
		       "legacy address (0x%x)\n", maple_rtc_addr);
	}

	rtc_iores.start = maple_rtc_addr;
	rtc_iores.end = maple_rtc_addr + 7;
	request_resource(&ioport_resource, &rtc_iores);

	maple_get_rtc_time(&tm);
	return mktime(tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
		      tm.tm_hour, tm.tm_min, tm.tm_sec);
}
コード例 #11
0
 * own rtc_lock ... and we won't worry about access during NMI.
 */
#define can_bank2	true

static inline unsigned char cmos_read_bank2(unsigned char addr)
{
	outb(addr, RTC_PORT(2));
	return inb(RTC_PORT(3));
}

static inline void cmos_write_bank2(unsigned char val, unsigned char addr)
{
	outb(addr, RTC_PORT(2));
<<<<<<< HEAD
<<<<<<< HEAD
	outb(val, RTC_PORT(3));
=======
	outb(val, RTC_PORT(2));
>>>>>>> 73a10a64c2f389351ff1594d88983f47c8de08f0
=======
	outb(val, RTC_PORT(2));
>>>>>>> ae1773bb70f3d7cf73324ce8fba787e01d8fa9f2
}

#else

#define can_bank2	false

static inline unsigned char cmos_read_bank2(unsigned char addr)
{
	return 0;
コード例 #12
0
ファイル: rtc-cmos.c プロジェクト: AICP/kernel_moto_shamu
static inline unsigned char cmos_read_bank2(unsigned char addr)
{
	outb(addr, RTC_PORT(2));
	return inb(RTC_PORT(3));
}
コード例 #13
0
ファイル: rtc-cmos.c プロジェクト: AICP/kernel_moto_shamu
static inline void cmos_write_bank2(unsigned char val, unsigned char addr)
{
	outb(addr, RTC_PORT(2));
	outb(val, RTC_PORT(3));
}
コード例 #14
0
ファイル: rtc.c プロジェクト: iPodLinux/linux-2.4.24-ipod
static int __init rtc_init(void)
{
#if defined(__alpha__) || defined(__mips__)
	unsigned int year, ctrl;
	unsigned long uip_watchdog;
	char *guess = NULL;
#endif
#ifdef __sparc__
	struct linux_ebus *ebus;
	struct linux_ebus_device *edev;
#ifdef __sparc_v9__
	struct isa_bridge *isa_br;
	struct isa_device *isa_dev;
#endif
#endif

#ifdef __sparc__
	for_each_ebus(ebus) {
		for_each_ebusdev(edev, ebus) {
			if(strcmp(edev->prom_name, "rtc") == 0) {
				rtc_port = edev->resource[0].start;
				rtc_irq = edev->irqs[0];
				goto found;
			}
		}
	}
#ifdef __sparc_v9__
	for_each_isa(isa_br) {
		for_each_isadev(isa_dev, isa_br) {
			if (strcmp(isa_dev->prom_name, "rtc") == 0) {
				rtc_port = isa_dev->resource.start;
				rtc_irq = isa_dev->irq;
				goto found;
			}
		}
	}
#endif
	printk(KERN_ERR "rtc_init: no PC rtc found\n");
	return -EIO;

found:
	if (rtc_irq == PCI_IRQ_NONE) {
		rtc_has_irq = 0;
		goto no_irq;
	}

	/*
	 * XXX Interrupt pin #7 in Espresso is shared between RTC and
	 * PCI Slot 2 INTA# (and some INTx# in Slot 1). SA_INTERRUPT here
	 * is asking for trouble with add-on boards. Change to SA_SHIRQ.
	 */
	if (request_irq(rtc_irq, rtc_interrupt, SA_INTERRUPT, "rtc", (void *)&rtc_port)) {
		/*
		 * Standard way for sparc to print irq's is to use
		 * __irq_itoa(). I think for EBus it's ok to use %d.
		 */
		printk(KERN_ERR "rtc: cannot register IRQ %d\n", rtc_irq);
		return -EIO;
	}
no_irq:
#else
	if (!request_region(RTC_PORT(0), RTC_IO_EXTENT, "rtc"))
	{
		printk(KERN_ERR "rtc: I/O port %d is not free.\n", RTC_PORT (0));
		return -EIO;
	}

#if RTC_IRQ
	if(request_irq(RTC_IRQ, rtc_interrupt, SA_INTERRUPT, "rtc", NULL))
	{
		/* Yeah right, seeing as irq 8 doesn't even hit the bus. */
		printk(KERN_ERR "rtc: IRQ %d is not free.\n", RTC_IRQ);
		release_region(RTC_PORT(0), RTC_IO_EXTENT);
		return -EIO;
	}
#endif

#endif /* __sparc__ vs. others */

	misc_register(&rtc_dev);
	create_proc_read_entry ("driver/rtc", 0, 0, rtc_read_proc, NULL);

#if defined(__alpha__) || defined(__mips__)
	rtc_freq = HZ;
	
	/* Each operating system on an Alpha uses its own epoch.
	   Let's try to guess which one we are using now. */
	
	uip_watchdog = jiffies;
	if (rtc_is_updating() != 0)
		while (jiffies - uip_watchdog < 2*HZ/100) { 
			barrier();
			cpu_relax();
		}
	
	spin_lock_irq(&rtc_lock);
	year = CMOS_READ(RTC_YEAR);
	ctrl = CMOS_READ(RTC_CONTROL);
	spin_unlock_irq(&rtc_lock);
	
	if (!(ctrl & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
		BCD_TO_BIN(year);       /* This should never happen... */
	
	if (year < 20) {
		epoch = 2000;
		guess = "SRM (post-2000)";
	} else if (year >= 20 && year < 48) {
		epoch = 1980;
		guess = "ARC console";
	} else if (year >= 48 && year < 72) {
		epoch = 1952;
		guess = "Digital UNIX";
#if defined(__mips__)
	} else if (year >= 72 && year < 74) {
		epoch = 2000;
		guess = "Digital DECstation";
#else
	} else if (year >= 70) {
		epoch = 1900;
		guess = "Standard PC (1900)";
#endif
	}
	if (guess)
		printk(KERN_INFO "rtc: %s epoch (%lu) detected\n", guess, epoch);
#endif
#if RTC_IRQ
	if (rtc_has_irq == 0)
		goto no_irq2;

	init_timer(&rtc_irq_timer);
	rtc_irq_timer.function = rtc_dropped_irq;
	spin_lock_irq(&rtc_lock);
	/* Initialize periodic freq. to CMOS reset default, which is 1024Hz */
	CMOS_WRITE(((CMOS_READ(RTC_FREQ_SELECT) & 0xF0) | 0x06), RTC_FREQ_SELECT);
	spin_unlock_irq(&rtc_lock);
	rtc_freq = 1024;
no_irq2:
#endif

	(void) init_sysctl();

	printk(KERN_INFO "Real Time Clock Driver v" RTC_VERSION "\n");

	return 0;
}
コード例 #15
0
	retval = x86_platform.get_wallclock();

	ts->tv_sec = retval;
	ts->tv_nsec = 0;
}

unsigned long long native_read_tsc(void)
{
	return __native_read_tsc();
}
EXPORT_SYMBOL(native_read_tsc);


static struct resource rtc_resources[] = {
	[0] = {
		.start	= RTC_PORT(0),
		.end	= RTC_PORT(1),
		.flags	= IORESOURCE_IO,
	},
	[1] = {
		.start	= RTC_IRQ,
		.end	= RTC_IRQ,
		.flags	= IORESOURCE_IRQ,
	}
};

static struct platform_device rtc_device = {
	.name		= "rtc_cmos",
	.id		= -1,
	.resource	= rtc_resources,
	.num_resources	= ARRAY_SIZE(rtc_resources),
コード例 #16
0
ファイル: rtc-std.c プロジェクト: chinnyannieb/empeg-hijack
static void std_rtc_write_data(unsigned char data, unsigned long addr)
{
	outb_p(addr, RTC_PORT(0));
	outb_p(data, RTC_PORT(1));
}
コード例 #17
0
ファイル: rtc-std.c プロジェクト: chinnyannieb/empeg-hijack
static unsigned char std_rtc_read_data(unsigned long addr)
{
	outb_p(addr, RTC_PORT(0));
	return inb_p(RTC_PORT(1));
}
コード例 #18
0
ファイル: malta-platform.c プロジェクト: jakev/CobraDroidBeta
		.regshift	= 3,
	},
	{ },
};

static struct platform_device malta_uart8250_device = {
	.name			= "serial8250",
	.id			= PLAT8250_DEV_PLATFORM,
	.dev			= {
		.platform_data	= uart8250_data,
	},
};

struct resource malta_rtc_resources[] = {
	{
		.start	= RTC_PORT(0),
		.end	= RTC_PORT(7),
		.flags	= IORESOURCE_IO,
	}, {
		.start	= RTC_IRQ,
		.end	= RTC_IRQ,
		.flags	= IORESOURCE_IRQ,
	}
};

static struct platform_device malta_rtc_device = {
	.name		= "rtc_cmos",
	.id		= -1,
	.resource	= malta_rtc_resources,
	.num_resources	= ARRAY_SIZE(malta_rtc_resources),
};