Commit 65f63268 authored by Andrey Filippov's avatar Andrey Filippov

bug fixes/cleanup, tested actual operation including SS

parent 2466226c
...@@ -417,6 +417,7 @@ static const struct si5338_drv_t drv_configs []={ ...@@ -417,6 +417,7 @@ static const struct si5338_drv_t drv_configs []={
static const char *out_dis_states[]= {"dis_hi-z","dis_low","dis_high","dis_always_on", NULL}; static const char *out_dis_states[]= {"dis_hi-z","dis_low","dis_high","dis_always_on", NULL};
static const char *out_en_states[]= {"output_en","output_dis", NULL}; static const char *out_en_states[]= {"output_en","output_dis", NULL};
static const char *out_pwr_states[]= {"output_power_up","output_power_down", NULL}; static const char *out_pwr_states[]= {"output_power_up","output_power_down", NULL};
static const char *ms_pwr_states[]= {"ms_power_up","ms_power_down", NULL};
...@@ -530,8 +531,10 @@ static ssize_t ms_p123_store(struct device *dev, struct device_attribute *attr, ...@@ -530,8 +531,10 @@ static ssize_t ms_p123_store(struct device *dev, struct device_attribute *attr,
static ssize_t ms_abc_show(struct device *dev, struct device_attribute *attr, char *buf); static ssize_t ms_abc_show(struct device *dev, struct device_attribute *attr, char *buf);
static ssize_t ms_abc_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count); static ssize_t ms_abc_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count);
static ssize_t ms_powerdown_show (struct device *dev, struct device_attribute *attr, char *buf); static ssize_t ms_pwr_states_show(struct device *dev, struct device_attribute *attr, char *buf);
static ssize_t ms_powerdown_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count); static ssize_t ms_pwr_states_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count);
static int set_ms_pwr_states(struct device *dev, const char * name, int chn);
static int get_ms_powerup_state(struct device *dev, char * buf, int chn);
static ssize_t ms_reset_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count); static ssize_t ms_reset_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count);
...@@ -559,12 +562,15 @@ static ssize_t out_div_by_freq_store(struct device *dev, struct device_attribute ...@@ -559,12 +562,15 @@ static ssize_t out_div_by_freq_store(struct device *dev, struct device_attribute
static ssize_t out_freq_show(struct device *dev, struct device_attribute *attr, char *buf); static ssize_t out_freq_show(struct device *dev, struct device_attribute *attr, char *buf);
static ssize_t out_freq_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count); static ssize_t out_freq_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count);
static ssize_t out_pwr_states_show(struct device *dev, struct device_attribute *attr, char *buf);
static ssize_t out_pwr_states_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count); static ssize_t out_pwr_states_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count);
static int set_out_pwr_states(struct device *dev, const char * name, int chn); static int set_out_pwr_states(struct device *dev, const char * name, int chn);
static int get_powerup_state(struct device *dev, char * buf, int chn); static int get_powerup_state(struct device *dev, char * buf, int chn);
static ssize_t out_en_states_show(struct device *dev, struct device_attribute *attr, char *buf);
static ssize_t out_en_states_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count); static ssize_t out_en_states_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count);
static int set_out_en_states(struct device *dev, const char * name, int chn); static int set_out_en_states(struct device *dev, const char * name, int chn);
static int get_enabled_state(struct device *dev, char * buf, int chn); static int get_enabled_state(struct device *dev, char * buf, int chn);
static ssize_t out_dis_states_show(struct device *dev, struct device_attribute *attr, char *buf);
static ssize_t out_dis_states_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count); static ssize_t out_dis_states_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count);
static int set_out_dis_states(struct device *dev, const char * name, int chn); static int set_out_dis_states(struct device *dev, const char * name, int chn);
static int get_disabled_state(struct device *dev, char * buf, int chn); static int get_disabled_state(struct device *dev, char * buf, int chn);
...@@ -594,6 +600,7 @@ static char * get_drv_txt(struct i2c_client *client, int chn); ...@@ -594,6 +600,7 @@ static char * get_drv_txt(struct i2c_client *client, int chn);
#endif #endif
static int make_config_out (struct device *dev); static int make_config_out (struct device *dev);
static ssize_t status_show (struct device *dev, struct device_attribute *attr, char *buf);
static ssize_t output_description_show (struct device *dev, struct device_attribute *attr, char *buf); static ssize_t output_description_show (struct device *dev, struct device_attribute *attr, char *buf);
static ssize_t output_route_show(struct device *dev, struct device_attribute *attr, char *buf); static ssize_t output_route_show(struct device *dev, struct device_attribute *attr, char *buf);
...@@ -642,6 +649,7 @@ static int get_out_frequency(struct i2c_client *client, u64* out_freq, int chn); ...@@ -642,6 +649,7 @@ static int get_out_frequency(struct i2c_client *client, u64* out_freq, int chn);
static int get_out_source(struct i2c_client *client, int chn); static int get_out_source(struct i2c_client *client, int chn);
static int set_out_source(struct i2c_client *client, int chn, int src); static int set_out_source(struct i2c_client *client, int chn, int src);
static int get_out_ms(struct i2c_client *client, int chn);
static int get_out_route(struct i2c_client *client, char* buf, int chn); static int get_out_route(struct i2c_client *client, char* buf, int chn);
static int set_out_route(struct i2c_client *client, const char* route, int chn); static int set_out_route(struct i2c_client *client, const char* route, int chn);
static int set_out_frequency_and_route (struct i2c_client *client, u64 *out_freq, int chn, int int_div); static int set_out_frequency_and_route (struct i2c_client *client, u64 *out_freq, int chn, int int_div);
...@@ -789,10 +797,9 @@ static DEVICE_ATTR(ms3_p123, SYSFS_PERMISSIONS, ms_p123_show, ms_p123_store); ...@@ -789,10 +797,9 @@ static DEVICE_ATTR(ms3_p123, SYSFS_PERMISSIONS, ms_p123_show, ms_p123_store);
static DEVICE_ATTR(ms3_abc, SYSFS_PERMISSIONS, ms_abc_show, ms_abc_store); static DEVICE_ATTR(ms3_abc, SYSFS_PERMISSIONS, ms_abc_show, ms_abc_store);
static DEVICE_ATTR(msn_p123, SYSFS_PERMISSIONS, ms_p123_show, ms_p123_store); static DEVICE_ATTR(msn_p123, SYSFS_PERMISSIONS, ms_p123_show, ms_p123_store);
static DEVICE_ATTR(msn_abc, SYSFS_PERMISSIONS, ms_abc_show, ms_abc_store); static DEVICE_ATTR(msn_abc, SYSFS_PERMISSIONS, ms_abc_show, ms_abc_store);
static DEVICE_ATTR(ms0_powerdown, SYSFS_PERMISSIONS, ms_powerdown_show, ms_powerdown_store);
static DEVICE_ATTR(ms1_powerdown, SYSFS_PERMISSIONS, ms_powerdown_show, ms_powerdown_store); static DEVICE_ATTR(ms_power_down, SYSFS_PERMISSIONS, ms_pwr_states_show, ms_pwr_states_store);
static DEVICE_ATTR(ms2_powerdown, SYSFS_PERMISSIONS, ms_powerdown_show, ms_powerdown_store); static DEVICE_ATTR(ms_power_up, SYSFS_PERMISSIONS, ms_pwr_states_show, ms_pwr_states_store);
static DEVICE_ATTR(ms3_powerdown, SYSFS_PERMISSIONS, ms_powerdown_show, ms_powerdown_store);
static DEVICE_ATTR(ms_reset, SYSFS_PERMISSIONS & SYSFS_WRITEONLY, NULL, ms_reset_store); static DEVICE_ATTR(ms_reset, SYSFS_PERMISSIONS & SYSFS_WRITEONLY, NULL, ms_reset_store);
static struct attribute *multisynth_attrs[] = { static struct attribute *multisynth_attrs[] = {
...@@ -806,10 +813,8 @@ static struct attribute *multisynth_attrs[] = { ...@@ -806,10 +813,8 @@ static struct attribute *multisynth_attrs[] = {
&dev_attr_ms3_abc.attr, &dev_attr_ms3_abc.attr,
&dev_attr_msn_p123.attr, &dev_attr_msn_p123.attr,
&dev_attr_msn_abc.attr, &dev_attr_msn_abc.attr,
&dev_attr_ms0_powerdown.attr, &dev_attr_ms_power_down.attr,
&dev_attr_ms1_powerdown.attr, &dev_attr_ms_power_up.attr,
&dev_attr_ms2_powerdown.attr,
&dev_attr_ms3_powerdown.attr,
&dev_attr_ms_reset.attr, &dev_attr_ms_reset.attr,
NULL NULL
}; };
...@@ -971,6 +976,9 @@ static const struct attribute_group dev_attr_output_group = { ...@@ -971,6 +976,9 @@ static const struct attribute_group dev_attr_output_group = {
.name = "output_clocks", .name = "output_clocks",
}; };
/* output drivers */ /* output drivers */
/* NOTE: state of the outputs changes with clock only, changing "dis_low" to "dis_high" does not work when disabled.
* Going through "dis_always_on" works
*/
#ifdef GENERATE_EXTRA #ifdef GENERATE_EXTRA
static DEVICE_ATTR(drv0_powerdown, SYSFS_PERMISSIONS, drv_powerdown_show, drv_powerdown_store); static DEVICE_ATTR(drv0_powerdown, SYSFS_PERMISSIONS, drv_powerdown_show, drv_powerdown_store);
static DEVICE_ATTR(drv1_powerdown, SYSFS_PERMISSIONS, drv_powerdown_show, drv_powerdown_store); static DEVICE_ATTR(drv1_powerdown, SYSFS_PERMISSIONS, drv_powerdown_show, drv_powerdown_store);
...@@ -1105,11 +1113,14 @@ static const struct attribute_group dev_attr_output_extra_group = { ...@@ -1105,11 +1113,14 @@ static const struct attribute_group dev_attr_output_extra_group = {
/* root directory */ /* root directory */
static DEVICE_ATTR(outputs, SYSFS_PERMISSIONS & SYSFS_READONLY, output_description_show, NULL); static DEVICE_ATTR(outputs, SYSFS_PERMISSIONS & SYSFS_READONLY, output_description_show, NULL);
static DEVICE_ATTR(status, SYSFS_PERMISSIONS & SYSFS_READONLY, status_show, NULL);
static struct attribute *root_dev_attrs[] = { static struct attribute *root_dev_attrs[] = {
&dev_attr_pre_init.attr, &dev_attr_pre_init.attr,
&dev_attr_pre_init_clear.attr, &dev_attr_pre_init_clear.attr,
&dev_attr_post_init.attr, &dev_attr_post_init.attr,
&dev_attr_outputs.attr, &dev_attr_outputs.attr,
&dev_attr_status.attr,
NULL NULL
}; };
static const struct attribute_group dev_attr_root_group = { static const struct attribute_group dev_attr_root_group = {
...@@ -1162,8 +1173,8 @@ static int make_config_out(struct device *dev) ...@@ -1162,8 +1173,8 @@ static int make_config_out(struct device *dev)
/* add outputs disabled states (write only) */ /* add outputs disabled states (write only) */
for (iout=0;out_dis_states[iout];iout++) { for (iout=0;out_dis_states[iout];iout++) {
dev_attrs[index].attr.name=out_dis_states[iout]; dev_attrs[index].attr.name=out_dis_states[iout];
dev_attrs[index].attr.mode=SYSFS_PERMISSIONS & SYSFS_WRITEONLY; dev_attrs[index].attr.mode=SYSFS_PERMISSIONS;
dev_attrs[index].show=NULL; dev_attrs[index].show=out_dis_states_show;
dev_attrs[index].store=out_dis_states_store; dev_attrs[index].store=out_dis_states_store;
pattrs[index]=&(dev_attrs[index].attr); pattrs[index]=&(dev_attrs[index].attr);
index++; index++;
...@@ -1171,8 +1182,8 @@ static int make_config_out(struct device *dev) ...@@ -1171,8 +1182,8 @@ static int make_config_out(struct device *dev)
/* add outputs enable (write only) */ /* add outputs enable (write only) */
for (iout=0;out_en_states[iout];iout++) { for (iout=0;out_en_states[iout];iout++) {
dev_attrs[index].attr.name=out_en_states[iout]; dev_attrs[index].attr.name=out_en_states[iout];
dev_attrs[index].attr.mode=SYSFS_PERMISSIONS & SYSFS_WRITEONLY; dev_attrs[index].attr.mode=SYSFS_PERMISSIONS;
dev_attrs[index].show=NULL; dev_attrs[index].show=out_en_states_show;
dev_attrs[index].store=out_en_states_store; dev_attrs[index].store=out_en_states_store;
pattrs[index]=&(dev_attrs[index].attr); pattrs[index]=&(dev_attrs[index].attr);
index++; index++;
...@@ -1180,14 +1191,13 @@ static int make_config_out(struct device *dev) ...@@ -1180,14 +1191,13 @@ static int make_config_out(struct device *dev)
/* add outputs enable (write only) */ /* add outputs enable (write only) */
for (iout=0;out_pwr_states[iout];iout++) { for (iout=0;out_pwr_states[iout];iout++) {
dev_attrs[index].attr.name=out_pwr_states[iout]; dev_attrs[index].attr.name=out_pwr_states[iout];
dev_attrs[index].attr.mode=SYSFS_PERMISSIONS & SYSFS_WRITEONLY; dev_attrs[index].attr.mode=SYSFS_PERMISSIONS;
dev_attrs[index].show=NULL; dev_attrs[index].show=out_pwr_states_show;
dev_attrs[index].store=out_pwr_states_store; dev_attrs[index].store=out_pwr_states_store;
pattrs[index]=&(dev_attrs[index].attr); pattrs[index]=&(dev_attrs[index].attr);
index++; index++;
} }
/* add outputs (readonly) */ /* add outputs (readonly) */
for (iout=0;out_names[iout];iout++) { for (iout=0;out_names[iout];iout++) {
dev_attrs[index].attr.name=out_names[iout]; dev_attrs[index].attr.name=out_names[iout];
...@@ -1212,9 +1222,18 @@ static int make_config_out(struct device *dev) ...@@ -1212,9 +1222,18 @@ static int make_config_out(struct device *dev)
return retval; return retval;
} }
static ssize_t status_show (struct device *dev, struct device_attribute *attr, char *buf)
{
int status;
struct i2c_client *client = to_i2c_client(dev);
if (((status=get_status(client)))<0) return status;
return sprintf(buf,"%d input clock: %s, feedback clock: %s, PLL lock: %s, calibration: %s\n",
status,(status & 0x4)?"LOST":"OK",(status & 0x8)?"LOST":"OK",(status & 0x10)?"LOST":"OK",(status & 0x10)?"IN PROGRESS":"DONE");
}
static ssize_t output_description_show (struct device *dev, struct device_attribute *attr, char *buf) static ssize_t output_description_show (struct device *dev, struct device_attribute *attr, char *buf)
{ {
int i,i1,rc,len=0,show_number; int i,i1,rc,len=0,show_number,ms;
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
for (i=0; out_names[i]; i++) if (strcmp(attr->attr.name,out_names[i]) == 0) break; for (i=0; out_names[i]; i++) if (strcmp(attr->attr.name,out_names[i]) == 0) break;
if (!out_names[i]) return -EINVAL; if (!out_names[i]) return -EINVAL;
...@@ -1249,6 +1268,15 @@ static ssize_t output_description_show (struct device *dev, struct device_attrib ...@@ -1249,6 +1268,15 @@ static ssize_t output_description_show (struct device *dev, struct device_attrib
if (((rc=get_out_route(client, buf,i)))<0) return rc; if (((rc=get_out_route(client, buf,i)))<0) return rc;
buf+=rc; buf+=rc;
len+=rc; len+=rc;
/* Show MSx power state only if it is used fro the output */
if (((ms=get_out_ms(client,i))) >= 0){
rc=sprintf(buf,", ");
buf+=rc;
len+=rc;
if (((rc=get_ms_powerup_state(dev, buf,i)))<0) return rc;
buf+=rc;
len+=rc;
}
rc=sprintf(buf,", disabled state: "); rc=sprintf(buf,", disabled state: ");
buf+=rc; buf+=rc;
...@@ -1270,8 +1298,7 @@ static ssize_t output_description_show (struct device *dev, struct device_attrib ...@@ -1270,8 +1298,7 @@ static ssize_t output_description_show (struct device *dev, struct device_attrib
if (((rc=get_enabled_state(dev, buf,i)))<0) return rc; if (((rc=get_enabled_state(dev, buf,i)))<0) return rc;
buf+=rc; buf+=rc;
len+=rc; len+=rc;
/* show spread spectum settings */
//show spread spectum settings
rc=sprintf(buf,", "); rc=sprintf(buf,", ");
buf+=rc; buf+=rc;
len+=rc; len+=rc;
...@@ -1813,24 +1840,55 @@ static ssize_t ms_abc_store(struct device *dev, struct device_attribute *attr, c ...@@ -1813,24 +1840,55 @@ static ssize_t ms_abc_store(struct device *dev, struct device_attribute *attr, c
return count; return count;
} }
static ssize_t ms_powerdown_show (struct device *dev, struct device_attribute *attr, char *buf) static ssize_t ms_pwr_states_show(struct device *dev, struct device_attribute *attr, char *buf)
{ {
int data,chn; int chn, i;
char * cp=buf;
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
chn=get_chn_from_name(attr->attr.name); /* uses first digit in the name */ for (chn=0;chn<4;chn++){
if (((data=get_ms_powerdown(client,chn)))<0) return data; for (i=0; ms_pwr_states[i]; i++) if (strcmp(attr->attr.name,ms_pwr_states[i]) == 0) {
return sprintf(buf, "%d\n",data); if (i== get_ms_powerdown(client, chn)){
buf+=sprintf(buf," %d",chn);
break;
}
}
}
buf+=sprintf(buf,"\n");
return buf-cp;
} }
static ssize_t ms_powerdown_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
static ssize_t ms_pwr_states_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{ {
int data,rc,chn; int chn, num_bytes,rc;
struct i2c_client *client = to_i2c_client(dev); while ((rc=sscanf(buf, "%d%n", &chn,&num_bytes))){
chn=get_chn_from_name(attr->attr.name); /* uses first digit in the name */ dev_dbg(dev,"buf=%s rc==%d chn=%d num_bytes=%d", buf, rc,chn,num_bytes);
sscanf(buf, "%d", &data); buf+=num_bytes;
if (((rc=set_ms_powerdown(client, data, chn)))<0) return rc; if (((rc=set_ms_pwr_states(dev, attr->attr.name, chn)))<0) return rc;
}
return count; return count;
} }
static int set_ms_pwr_states(struct device *dev, const char * name, int chn)
{
int i,rc;
struct i2c_client *client = to_i2c_client(dev);
dev_dbg(dev,"name=%s chn=%d", name,chn);
if (((rc=_verify_output_channel(client,chn)))<0) return rc;
for (i=0; ms_pwr_states[i]; i++) if (strcmp(name,ms_pwr_states[i]) == 0) {
if (((rc=set_ms_powerdown(client, i, chn)))<0) return rc;
return 0;
}
return -EINVAL;
}
static int get_ms_powerup_state(struct device *dev, char * buf, int chn)
{
int index;
struct i2c_client *client = to_i2c_client(dev);
if (((index=get_ms_powerdown(client,chn)))<0) return index;
return sprintf (buf,ms_pwr_states[index]);
}
static ssize_t ms_reset_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) static ssize_t ms_reset_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{ {
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
...@@ -1885,7 +1943,7 @@ static ssize_t ss_vals_store(struct device *dev, struct device_attribute *attr, ...@@ -1885,7 +1943,7 @@ static ssize_t ss_vals_store(struct device *dev, struct device_attribute *attr,
if (((state= get_ss_state(client, chn)))<0) return state; if (((state= get_ss_state(client, chn)))<0) return state;
if (((rate= get_ss_down_rate(client, chn)))<0) return rate; if (((rate= get_ss_down_rate(client, chn)))<0) return rate;
if (((amp= get_ss_down_amplitude(client, chn)))<0) return amp; if (((amp= get_ss_down_amplitude(client, chn)))<0) return amp;
num_items=sscanf(buf, "%d %d %d", &state, &rate, &amp); num_items=sscanf(buf, "%d %d %d", &state, &amp, &rate);
if (num_items>1){ if (num_items>1){
if (((rc= store_ss_down_parameters(client, rate, amp, chn)))<0) return rc; if (((rc= store_ss_down_parameters(client, rate, amp, chn)))<0) return rc;
} }
...@@ -1943,12 +2001,6 @@ static ssize_t ss_regs_hex_store(struct device *dev, struct device_attribute *at ...@@ -1943,12 +2001,6 @@ static ssize_t ss_regs_hex_store(struct device *dev, struct device_attribute *at
return count; return count;
} }
static ssize_t pre_init_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) static ssize_t pre_init_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{ {
int rc,clear_all; int rc,clear_all;
...@@ -2139,7 +2191,22 @@ static ssize_t out_div_by_freq_store(struct device *dev, struct device_attribute ...@@ -2139,7 +2191,22 @@ static ssize_t out_div_by_freq_store(struct device *dev, struct device_attribute
return count; return count;
} }
static ssize_t out_pwr_states_show(struct device *dev, struct device_attribute *attr, char *buf)
{
int chn, i;
char * cp=buf;
struct i2c_client *client = to_i2c_client(dev);
for (chn=0;chn<4;chn++){
for (i=0; out_pwr_states[i]; i++) if (strcmp(attr->attr.name,out_pwr_states[i]) == 0) {
if (i== get_drv_powerdown(client, chn)){
buf+=sprintf(buf," %d",chn);
break;
}
}
}
buf+=sprintf(buf,"\n");
return buf-cp;
}
static ssize_t out_pwr_states_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) static ssize_t out_pwr_states_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{ {
...@@ -2173,6 +2240,23 @@ static int get_powerup_state(struct device *dev, char * buf, int chn) ...@@ -2173,6 +2240,23 @@ static int get_powerup_state(struct device *dev, char * buf, int chn)
return sprintf (buf,out_pwr_states[index]); return sprintf (buf,out_pwr_states[index]);
} }
static ssize_t out_en_states_show(struct device *dev, struct device_attribute *attr, char *buf)
{
int chn, i;
char * cp=buf;
struct i2c_client *client = to_i2c_client(dev);
for (chn=0;chn<4;chn++){
for (i=0; out_en_states[i]; i++) if (strcmp(attr->attr.name,out_en_states[i]) == 0) {
if (i== get_drv_disable(client, chn)){
buf+=sprintf(buf," %d",chn);
break;
}
}
}
buf+=sprintf(buf,"\n");
return buf-cp;
}
static ssize_t out_en_states_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) static ssize_t out_en_states_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{ {
int chn, num_bytes,rc; int chn, num_bytes,rc;
...@@ -2205,6 +2289,22 @@ static int get_enabled_state(struct device *dev, char * buf, int chn) ...@@ -2205,6 +2289,22 @@ static int get_enabled_state(struct device *dev, char * buf, int chn)
return sprintf (buf,out_en_states[index]); return sprintf (buf,out_en_states[index]);
} }
static ssize_t out_dis_states_show(struct device *dev, struct device_attribute *attr, char *buf)
{
int chn, i;
char * cp=buf;
struct i2c_client *client = to_i2c_client(dev);
for (chn=0;chn<4;chn++){
for (i=0; out_dis_states[i]; i++) if (strcmp(attr->attr.name,out_dis_states[i]) == 0) {
if (i== get_drv_disabled_state(client, chn)){
buf+=sprintf(buf," %d",chn);
break;
}
}
}
buf+=sprintf(buf,"\n");
return buf-cp;
}
static ssize_t out_dis_states_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) static ssize_t out_dis_states_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{ {
int chn, num_bytes,rc; int chn, num_bytes,rc;
...@@ -2235,6 +2335,7 @@ static int get_disabled_state(struct device *dev, char * buf, int chn) ...@@ -2235,6 +2335,7 @@ static int get_disabled_state(struct device *dev, char * buf, int chn)
if (((index=get_drv_disabled_state(client,chn)))<0) return index; if (((index=get_drv_disabled_state(client,chn)))<0) return index;
return sprintf (buf,out_dis_states[index]); return sprintf (buf,out_dis_states[index]);
} }
#ifdef GENERATE_EXTRA #ifdef GENERATE_EXTRA
static ssize_t drv_powerdown_show (struct device *dev, struct device_attribute *attr, char *buf) static ssize_t drv_powerdown_show (struct device *dev, struct device_attribute *attr, char *buf)
{ {
...@@ -3013,6 +3114,19 @@ static int set_out_source(struct i2c_client *client, int chn, int src) ...@@ -3013,6 +3114,19 @@ static int set_out_source(struct i2c_client *client, int chn, int src)
} }
return write_field (client, (u8) src, awe_rdiv_in[chn]); return write_field (client, (u8) src, awe_rdiv_in[chn]);
} }
static int get_out_ms(struct i2c_client *client, int chn)
{
int rc,out_src;
if (((rc=_verify_output_channel(client,chn)))<0) return rc;
if (((out_src=get_out_source(client, chn)))<0) return out_src;
switch (out_src){
case 5: return 0;
case 6: return chn;
}
return -1;
}
/* Examples: /* Examples:
* "IN12:2:4" * "IN12:2:4"
* "XO:1:1" * "XO:1:1"
...@@ -3489,7 +3603,7 @@ static int get_ms_powerdown(struct i2c_client *client, int chn) ...@@ -3489,7 +3603,7 @@ static int get_ms_powerdown(struct i2c_client *client, int chn)
{ {
int rc; int rc;
if (((rc=_verify_output_channel(client,chn)))<0) return rc; if (((rc=_verify_output_channel(client,chn)))<0) return rc;
return read_field (client, awe_drv_powerdown[chn]); return read_field (client, awe_ms_powerdown[chn]);
} }
static int set_ms_powerdown(struct i2c_client *client, int typ, int chn) static int set_ms_powerdown(struct i2c_client *client, int typ, int chn)
...@@ -3497,7 +3611,7 @@ static int set_ms_powerdown(struct i2c_client *client, int typ, int chn) ...@@ -3497,7 +3611,7 @@ static int set_ms_powerdown(struct i2c_client *client, int typ, int chn)
int rc; int rc;
if (((rc=_verify_output_channel(client,chn)))<0) return rc; if (((rc=_verify_output_channel(client,chn)))<0) return rc;
if (typ) typ=1; if (typ) typ=1;
return write_field (client, (u8) typ, awe_drv_powerdown[chn]); return write_field (client, (u8) typ, awe_ms_powerdown[chn]);
} }
static int ms_to_p123(u64* ms,u32 * p123) static int ms_to_p123(u64* ms,u32 * p123)
......
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