type
stringclasses
5 values
content
stringlengths
9
163k
functions
__init smp_space_timers(unsigned int max_cpus) { int i; u64 previous_tb = per_cpu(last_jiffy, boot_cpuid); /* make sure tb > per_cpu(last_jiffy, cpu) for all cpus always */ previous_tb -= tb_ticks_per_jiffy; for_each_possible_cpu(i) { if (i == boot_cpuid) continue; per_cpu(last_jiffy, i) = previous_tb; }
functions
long sched_clock(void) { if (__USE_RTC()) return get_rtc(); return mulhdu(get_tb() - boot_tb, tb_to_ns_scale) << tb_to_ns_shift; }
functions
__init get_freq(char *name, int cells, unsigned long *val) { struct device_node *cpu; const unsigned int *fp; int found = 0; /* The cpu node should have timebase and clock frequency properties */ cpu = of_find_node_by_type(NULL, "cpu"); if (cpu) { fp = of_get_property(cpu, name, NULL); if (fp) { found = ...
functions
void start_cpu_decrementer(void) { #if defined(CONFIG_BOOKE) || defined(CONFIG_40x) /* Clear any pending timer interrupts */ mtspr(SPRN_TSR, TSR_ENW | TSR_WIS | TSR_DIS | TSR_FIS); /* Enable decrementer interrupt */ mtspr(SPRN_TCR, TCR_DIE); #endif /* defined(CONFIG_BOOKE) || defined(CONFIG_40x) */ }
functions
__init generic_calibrate_decr(void) { ppc_tb_freq = DEFAULT_TB_FREQ; /* hardcoded default */ if (!get_freq("ibm,extended-timebase-frequency", 2, &ppc_tb_freq) && !get_freq("timebase-frequency", 1, &ppc_tb_freq)) { printk(KERN_ERR "WARNING: Estimating decrementer frequency " "(not found)\n"); }
functions
int update_persistent_clock(struct timespec now) { struct rtc_time tm; if (!ppc_md.set_rtc_time) return 0; to_tm(now.tv_sec + 1 + timezone_offset, &tm); tm.tm_year -= 1900; tm.tm_mon -= 1; return ppc_md.set_rtc_time(&tm); }
functions
void __read_persistent_clock(struct timespec *ts) { struct rtc_time tm; static int first = 1; ts->tv_nsec = 0; /* XXX this is a litle fragile but will work okay in the short term */ if (first) { first = 0; if (ppc_md.time_init) timezone_offset = ppc_md.time_init(); /* get_boot_time() isn't guaranteed to...
functions
void read_persistent_clock(struct timespec *ts) { __read_persistent_clock(ts); /* Sanitize it in case real time clock is set below EPOCH */ if (ts->tv_sec < 0) { ts->tv_sec = 0; ts->tv_nsec = 0; }
functions
cycle_t rtc_read(struct clocksource *cs) { return (cycle_t)get_rtc(); }
functions
cycle_t timebase_read(struct clocksource *cs) { return (cycle_t)get_tb(); }
functions
void update_vsyscall(struct timespec *wall_time, struct clocksource *clock, u32 mult) { u64 t2x, stamp_xsec; if (clock != &clocksource_timebase) return; /* Make userspace gettimeofday spin until we're done. */ ++vdso_data->tb_update_count; smp_mb(); /* XXX this assumes clock->shift == 22 */ /* 461168...
functions
void update_vsyscall_tz(void) { /* Make userspace gettimeofday spin until we're done. */ ++vdso_data->tb_update_count; smp_mb(); vdso_data->tz_minuteswest = sys_tz.tz_minuteswest; vdso_data->tz_dsttime = sys_tz.tz_dsttime; smp_mb(); ++vdso_data->tb_update_count; }
functions
__init clocksource_init(void) { struct clocksource *clock; if (__USE_RTC()) clock = &clocksource_rtc; else clock = &clocksource_timebase; clock->mult = clocksource_hz2mult(tb_ticks_per_sec, clock->shift); if (clocksource_register(clock)) { printk(KERN_ERR "clocksource: %s is already registered\n", ...
functions
int decrementer_set_next_event(unsigned long evt, struct clock_event_device *dev) { __get_cpu_var(decrementers).next_tb = get_tb_or_rtc() + evt; set_dec(evt); return 0; }
functions
void decrementer_set_mode(enum clock_event_mode mode, struct clock_event_device *dev) { if (mode != CLOCK_EVT_MODE_ONESHOT) decrementer_set_next_event(DECREMENTER_MAX, dev); }
functions
uint64_t div_sc64(unsigned long ticks, unsigned long nsec, int shift) { uint64_t tmp = ((uint64_t)ticks) << shift; do_div(tmp, nsec); return tmp; }
functions
__init setup_clockevent_multiplier(unsigned long hz) { u64 mult, shift = 32; while (1) { mult = div_sc64(hz, NSEC_PER_SEC, shift); if (mult && (mult >> 32UL) == 0UL) break; shift--; }
functions
void register_decrementer_clockevent(int cpu) { struct clock_event_device *dec = &per_cpu(decrementers, cpu).event; *dec = decrementer_clockevent; dec->cpumask = cpumask_of(cpu); printk(KERN_DEBUG "clockevent: %s mult[%x] shift[%d] cpu[%d]\n", dec->name, dec->mult, dec->shift, cpu); clockevents_register...
functions
__init init_decrementer_clockevent(void) { int cpu = smp_processor_id(); setup_clockevent_multiplier(ppc_tb_freq); decrementer_clockevent.max_delta_ns = clockevent_delta2ns(DECREMENTER_MAX, &decrementer_clockevent); decrementer_clockevent.min_delta_ns = clockevent_delta2ns(2, &decrementer_clockevent); regist...
functions
void secondary_cpu_time_init(void) { /* Start the decrementer on CPUs that have manual control * such as BookE */ start_cpu_decrementer(); /* FIME: Should make unrelatred change to move snapshot_timebase * call here ! */ register_decrementer_clockevent(smp_processor_id()); }
functions
__init time_init(void) { unsigned long flags; struct div_result res; u64 scale, x; unsigned shift; if (__USE_RTC()) { /* 601 processor: dec counts down by 128 every 128ns */ ppc_tb_freq = 1000000000; tb_last_jiffy = get_rtcl(); }
functions
void GregorianDay(struct rtc_time * tm) { int leapsToDate; int lastYear; int day; int MonthOffset[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }
functions
void to_tm(int tim, struct rtc_time * tm) { register int i; register long hms, day; day = tim / SECDAY; hms = tim % SECDAY; /* Hours, minutes, seconds are easy */ tm->tm_hour = hms / 3600; tm->tm_min = (hms % 3600) / 60; tm->tm_sec = (hms % 3600) % 60; /* Number of years in days */ for (i = STARTOFTIM...
functions
unsigned mulhwu_scale_factor(unsigned inscale, unsigned outscale) { unsigned mlt=0, tmp, err; /* No concern for performance, it's done once: use a stupid * but safe and compact method to find the multiplier. */ for (tmp = 1U<<31; tmp != 0; tmp >>= 1) { if (mu...
functions
void div128_by_32(u64 dividend_high, u64 dividend_low, unsigned divisor, struct div_result *dr) { unsigned long a, b, c, d; unsigned long w, x, y, z; u64 ra, rb, rc; a = dividend_high >> 32; b = dividend_high & 0xffffffff; c = dividend_low >> 32; d = dividend_low & 0xffffffff; w = a / divisor; ra = ((u64...
functions
void calibrate_delay(void) { /* Some generic code (such as spinlock debug) use loops_per_jiffy * as the number of __delay(1) in a jiffy, so make it so */ loops_per_jiffy = tb_ticks_per_jiffy; }
functions
__init rtc_init(void) { struct platform_device *pdev; if (!ppc_md.get_rtc_time) return -ENODEV; pdev = platform_device_register_simple("rtc-generic", -1, NULL, 0); if (IS_ERR(pdev)) return PTR_ERR(pdev); return 0; }
includes
#include <linux/slab.h>
includes
#include <linux/earlysuspend.h>
includes
#include <linux/err.h>
includes
#include <linux/module.h>
includes
#include <linux/platform_device.h>
includes
#include <linux/power_supply.h>
includes
#include <linux/sched.h>
includes
#include <linux/signal.h>
includes
#include <linux/uaccess.h>
includes
#include <linux/wait.h>
includes
#include <linux/workqueue.h>
includes
#include <asm/atomic.h>
includes
#include <mach/msm_rpcrouter.h>
includes
#include <mach/msm_battery.h>
defines
#define DEBUG 1
defines
#define BATTERY_RPC_PROG 0x30000089
defines
#define BATTERY_RPC_VER_1_1 0x00010001
defines
#define BATTERY_RPC_VER_2_1 0x00020001
defines
#define BATTERY_RPC_VER_4_1 0x00040001
defines
#define BATTERY_RPC_VER_5_1 0x00050001
defines
#define BATTERY_RPC_CB_PROG (BATTERY_RPC_PROG | 0x01000000)
defines
#define CHG_RPC_PROG 0x3000001a
defines
#define CHG_RPC_VER_1_1 0x00010001
defines
#define CHG_RPC_VER_1_3 0x00010003
defines
#define CHG_RPC_VER_2_2 0x00020002
defines
#define CHG_RPC_VER_3_1 0x00030001
defines
#define CHG_RPC_VER_4_1 0x00040001
defines
#define BATTERY_REGISTER_PROC 2
defines
#define BATTERY_MODIFY_CLIENT_PROC 4
defines
#define BATTERY_DEREGISTER_CLIENT_PROC 5
defines
#define BATTERY_READ_MV_PROC 12
defines
#define BATTERY_ENABLE_DISABLE_FILTER_PROC 14
defines
#define VBATT_FILTER 2
defines
#define BATTERY_CB_TYPE_PROC 1
defines
#define BATTERY_CB_ID_ALL_ACTIV 1
defines
#define BATTERY_CB_ID_LOW_VOL 2
defines
#define BATTERY_LOW 3200
defines
#define BATTERY_HIGH 4300
defines
#define ONCRPC_CHG_GET_GENERAL_STATUS_PROC 12
defines
#define ONCRPC_CHARGER_API_VERSIONS_PROC 0xffffffff
defines
#define BATT_RPC_TIMEOUT 5000 /* 5 sec */
defines
#define INVALID_BATT_HANDLE -1
defines
#define RPC_TYPE_REQ 0
defines
#define RPC_TYPE_REPLY 1
defines
#define RPC_REQ_REPLY_COMMON_HEADER_SIZE (3 * sizeof(uint32_t))
defines
#define DBG_LIMIT(x...) do {if (printk_ratelimit()) pr_debug(x); } while (0)
defines
#define DBG_LIMIT(x...) do {} while (0)
defines
#define be32_to_cpu_self(v) (v = be32_to_cpu(v))
structs
struct rpc_reply_batt_chg_v1 { struct rpc_reply_hdr hdr; u32 more_data; u32 charger_status; u32 charger_type; u32 battery_status; u32 battery_level; u32 battery_voltage; u32 battery_temp; };
structs
struct rpc_reply_batt_chg_v2 { struct rpc_reply_batt_chg_v1 v1; u32 is_charger_valid; u32 is_charging; u32 is_battery_valid; u32 ui_event; };
structs
struct msm_battery_info { u32 voltage_max_design; u32 voltage_min_design; u32 chg_api_version; u32 batt_technology; u32 batt_api_version; u32 avail_chg_sources; u32 current_chg_source; u32 batt_status; u32 batt_health; u32 charger_valid; u32 batt_valid; u32 batt_capacity; /* in percentage */ u32 charger...
structs
struct msm_batt_get_volt_ret_data { u32 battery_voltage; };
structs
struct batt_modify_client_req { u32 client_handle; /* The voltage at which callback (CB) should be called. */ u32 desired_batt_voltage; /* The direction when the CB should be called. */ u32 voltage_direction; /* The registered callback to be called when voltage and * direction specs are met. */ u32 batt_cb...
structs
struct batt_modify_client_rep { u32 result; };
structs
struct msm_batt_vbatt_filter_req { u32 batt_handle; u32 enable_filter; u32 vbatt_filter; };
structs
struct msm_batt_vbatt_filter_rep { u32 result; };
structs
struct batt_client_registration_req { /* The voltage at which callback (CB) should be called. */ u32 desired_batt_voltage; /* The direction when the CB should be called. */ u32 voltage_direction; /* The registered callback to be called when voltage and * direction specs are met. */ u32 batt_cb_id; /* The ca...
structs
struct batt_client_registration_req_4_1 { /* The voltage at which callback (CB) should be called. */ u32 desired_batt_voltage; /* The direction when the CB should be called. */ u32 voltage_direction; /* The registered callback to be called when voltage and * direction specs are met. */ u32 batt_cb_id; /* Th...
structs
struct batt_client_registration_rep { u32 batt_handle; };
structs
struct batt_client_registration_rep_4_1 { u32 batt_handle; u32 more_data; u32 err; };
structs
struct batt_client_deregister_req { u32 batt_handle; };
structs
struct batt_client_deregister_rep { u32 batt_error; };
structs
struct rpc_rep_chg_api_ver { struct rpc_reply_hdr hdr; u32 num_of_chg_api_versions; u32 *chg_api_versions; };
functions
int msm_power_get_property(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val) { switch (psp) { case POWER_SUPPLY_PROP_ONLINE: if (psy->type == POWER_SUPPLY_TYPE_MAINS) { val->intval = msm_batt_info.current_chg_source & AC_CHG ? 1 : 0; }
functions
int msm_batt_power_get_property(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val) { switch (psp) { case POWER_SUPPLY_PROP_STATUS: val->intval = msm_batt_info.batt_status; break; case POWER_SUPPLY_PROP_HEALTH: val->intval = msm_batt_info.batt_health...
functions
int msm_batt_get_volt_ret_func(struct msm_rpc_client *batt_client, void *buf, void *data) { struct msm_batt_get_volt_ret_data *data_ptr, *buf_ptr; data_ptr = (struct msm_batt_get_volt_ret_data *)data; buf_ptr = (struct msm_batt_get_volt_ret_data *)buf; data_ptr->battery_voltage = be32_to_cpu(buf_ptr->b...
functions
u32 msm_batt_get_vbatt_voltage(void) { int rc; struct msm_batt_get_volt_ret_data rep; rc = msm_rpc_client_req(msm_batt_info.batt_client, BATTERY_READ_MV_PROC, NULL, NULL, msm_batt_get_volt_ret_func, &rep, msecs_to_jiffies(BATT_RPC_TIMEOUT)); if (rc < 0) { pr_err("%s: FAIL: vbatt get volt. rc=%d\n",...
functions
int msm_batt_get_batt_chg_status(void) { int rc; struct rpc_req_batt_chg { struct rpc_request_hdr hdr; u32 more_data; }
functions
void msm_batt_update_psy_status(void) { static u32 unnecessary_event_count; u32 charger_status; u32 charger_type; u32 battery_status; u32 battery_level; u32 battery_voltage; u32 battery_temp; struct power_supply *supp; if (msm_batt_get_batt_chg_status()) return; charger_status = rep_batt_chg.v1.charge...
functions
else if (charger_type == CHARGER_TYPE_WALL) { DBG_LIMIT("BATT: AC Wall changer plugged in\n"); msm_batt_info.current_chg_source = AC_CHG; supp = &msm_psy_ac; }
functions
else if (battery_status == BATTERY_STATUS_BAD_TEMP) { DBG_LIMIT("BATT: Battery overheat.\n"); msm_batt_info.batt_health = POWER_SUPPLY_HEALTH_OVERHEAT; }
functions
int msm_batt_modify_client_arg_func(struct msm_rpc_client *batt_client, void *buf, void *data) { struct batt_modify_client_req *batt_modify_client_req = (struct batt_modify_client_req *)data; u32 *req = (u32 *)buf; int size = 0; *req = cpu_to_be32(batt_modify_client_req->client_handle); size += sizeo...
functions
int msm_batt_modify_client_ret_func(struct msm_rpc_client *batt_client, void *buf, void *data) { struct batt_modify_client_rep *data_ptr, *buf_ptr; data_ptr = (struct batt_modify_client_rep *)data; buf_ptr = (struct batt_modify_client_rep *)buf; data_ptr->result = be32_to_cpu(buf_ptr->result); retur...