void s5p6818_timer_stop(virtual_addr_t virt, int ch) { u32_t val; val = read32(virt + TIMER_TCON); val &= ~(TCON_START(ch)); write32(virt + TIMER_TCON, val); }
void s5p4418_timer_stop(int ch) { u32_t val; val = read32(phys_to_virt(S5P4418_TIMER_TCON)); val &= ~(TCON_START(ch)); write32(phys_to_virt(S5P4418_TIMER_TCON), val); }
void s5p6818_timer_start(virtual_addr_t virt, int ch, int oneshot) { u32_t val; val = read32(virt + TIMER_TCON); val &= ~(TCON_AUTORELOAD(ch) | TCON_START(ch)); if(!oneshot) val |= TCON_AUTORELOAD(ch); val |= TCON_MANUALUPDATE(ch); write32(virt + TIMER_TCON, val); val = read32(virt + TIMER_TCON); val &= ~(TCON_AUTORELOAD(ch) | TCON_MANUALUPDATE(ch)); if(!oneshot) val |= TCON_AUTORELOAD(ch); val |= TCON_START(ch); write32(virt + TIMER_TCON, val); }
void s5p4418_timer_start(int ch, int oneshot) { u32_t val; val = read32(phys_to_virt(S5P4418_TIMER_TCON)); val &= ~(TCON_AUTORELOAD(ch) | TCON_START(ch)); if(!oneshot) val |= TCON_AUTORELOAD(ch); val |= TCON_MANUALUPDATE(ch); write32(phys_to_virt(S5P4418_TIMER_TCON), val); val = read32(phys_to_virt(S5P4418_TIMER_TCON)); val &= ~(TCON_AUTORELOAD(ch) | TCON_MANUALUPDATE(ch)); if(!oneshot) val |= TCON_AUTORELOAD(ch); val |= TCON_START(ch); write32(phys_to_virt(S5P4418_TIMER_TCON), val); }
int pwm_enable(int pwm_id) { const struct s5p_timer *pwm = (struct s5p_timer *)samsung_get_base_timer(); unsigned long tcon; tcon = readl(&pwm->tcon); tcon |= TCON_START(pwm_id); writel(tcon, &pwm->tcon); return 0; }
void s5p6818_timer_disable(virtual_addr_t virt, int ch) { u32_t val; val = read32(virt + TIMER_TSTAT); val &= ~(0x1f << 5 | 0x1 << ch); val |= (0x1 << (ch + 5)); write32(virt + TIMER_TSTAT, val); val = read32(virt + TIMER_TCON); val &= ~(TCON_START(ch)); write32(virt + TIMER_TCON, val); if(ch< 2) clk_disable("DIV-TIMER-PRESCALER0"); else clk_disable("DIV-TIMER-PRESCALER1"); }
void s5p4418_timer_disable(int ch) { u32_t val; val = read32(phys_to_virt(S5P4418_TIMER_TSTAT)); val &= ~(0x1f << 5 | 0x1 << ch); val |= (0x1 << (ch + 5)); write32(phys_to_virt(S5P4418_TIMER_TSTAT), val); val = read32(phys_to_virt(S5P4418_TIMER_TCON)); val &= ~(TCON_START(ch)); write32(phys_to_virt(S5P4418_TIMER_TCON), val); if(ch< 2) clk_disable("DIV-TIMER-PRESCALER0"); else clk_disable("DIV-TIMER-PRESCALER1"); }
void cpu_initclocks(void) { struct s3c24x0_softc *sc = (struct s3c24x0_softc *)s3c2xx0_softc; long tc; struct resource *irq; int rid = 0; void *ihl; int err, prescaler; int pclk = s3c2xx0_softc->sc_pclk; bus_space_tag_t iot = sc->sc_sx.sc_iot; bus_space_handle_t ioh = sc->sc_timer_ioh; uint32_t reg; device_t dev = timer_softc.dev; /* We have already been initialized */ if (timer4_reload_value != 0) return; #define time_constant(hz) (TIMER_FREQUENCY(pclk) /(hz)/ prescaler) #define calc_time_constant(hz) \ do { \ prescaler = 1; \ do { \ ++prescaler; \ tc = time_constant(hz); \ } while( tc > 65536 ); \ } while(0) /* Use the channels 4 and 3 for hardclock and statclock, respectively */ /* stop all timers */ bus_space_write_4(iot, ioh, TIMER_TCON, 0); /* calc suitable prescaler value */ calc_time_constant(hz); timer4_prescaler = prescaler; timer4_reload_value = TIMER_FREQUENCY(pclk) / hz / prescaler; timer4_mseccount = TIMER_FREQUENCY(pclk)/timer4_prescaler/1000 ; bus_space_write_4(iot, ioh, TIMER_TCNTB(4), ((prescaler - 1) << 16) | (timer4_reload_value - 1)); printf("clock: hz=%d PCLK=%d prescaler=%d tc=%ld\n", hz, pclk, prescaler, tc); irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, S3C24X0_INT_TIMER4, S3C24X0_INT_TIMER4, 1, RF_ACTIVE); if (!irq) panic("Unable to allocate the clock irq handler.\n"); err = bus_setup_intr(dev, irq, INTR_TYPE_CLK, clock_intr, NULL, NULL, &ihl); if (err != 0) panic("Unable to setup the clock irq handler.\n"); /* set prescaler1 */ reg = bus_space_read_4(iot, ioh, TIMER_TCFG0); bus_space_write_4(iot, ioh, TIMER_TCFG0, (reg & ~0xff00) | ((prescaler-1) << 8)); /* divider 1/16 for ch #4 */ reg = bus_space_read_4(iot, ioh, TIMER_TCFG1); bus_space_write_4(iot, ioh, TIMER_TCFG1, (reg & ~(TCFG1_MUX_MASK(4))) | (TCFG1_MUX_DIV16 << TCFG1_MUX_SHIFT(4)) ); /* start timers */ reg = bus_space_read_4(iot, ioh, TIMER_TCON); reg &= ~(TCON_MASK(4)); /* load the time constant */ bus_space_write_4(iot, ioh, TIMER_TCON, reg | TCON_MANUALUPDATE(4)); /* set auto reload and start */ bus_space_write_4(iot, ioh, TIMER_TCON, reg | TCON_AUTORELOAD(4) | TCON_START(4) ); s3c24x0_timer_timecounter.tc_frequency = TIMER_FREQUENCY(pclk) / timer4_prescaler; tc_init(&s3c24x0_timer_timecounter); }