Esempio n. 1
0
/* return raw value from the reg, then it may do bcd convertion if needed */
static inline int rtc_read_reg(struct ac100 *ac100, int reg)
{
#if 0
	arisc_rsb_block_cfg_t rsb_data;
	unsigned char addr;
	unsigned int data;

	addr = (unsigned char)reg;
	rsb_data.len = 1;
	rsb_data.datatype = RSB_DATA_TYPE_HWORD;
	rsb_data.msgattr = ARISC_MESSAGE_ATTR_SOFTSYN;
	rsb_data.devaddr = RSB_RTSADDR_AC100;
	rsb_data.regaddr = &addr;
	rsb_data.data = &data;

	/* read axp registers */
	if (arisc_rsb_read_block_data(&rsb_data)) {
		pr_err("%s(%d) err: read reg-0x%x failed", __func__, __LINE__, reg);
		return -EPERM;
	}
	return data;
#else
	return ac100_reg_read(ac100, reg);
#endif
}
Esempio n. 2
0
static u32 ac100_readl(void __iomem * reg)
{
    arisc_rsb_block_cfg_t rsb_data;
    unsigned char addr;
    unsigned int val;

    addr = (unsigned char)((unsigned long)reg);
    rsb_data.len = 1;
    rsb_data.datatype = RSB_DATA_TYPE_HWORD;
    rsb_data.msgattr = ARISC_MESSAGE_ATTR_SOFTSYN;
    rsb_data.devaddr = RSB_RTSADDR_AC100;
    rsb_data.regaddr =  &addr;
    rsb_data.data = &val;
    /* read registers */
    if (arisc_rsb_read_block_data(&rsb_data))
        pr_err("%s(%d) err: read reg-0x%x failed", __func__, __LINE__, (unsigned int __force)reg);
    return val;
}
Esempio n. 3
0
/**
 * acx00_rsb_reg_read: Read a single ACX00X00 register.
 *
 * @reg: Register to read.
 */
int acx00_rsb_reg_read(unsigned short reg)
{
	int	ret;
	arisc_rsb_block_cfg_t rsb_data;
	unsigned char addr;
	unsigned int data;

	addr = (unsigned char)reg;
	rsb_data.len = 1;
	rsb_data.datatype = RSB_DATA_TYPE_HWORD;
	rsb_data.msgattr = ARISC_MESSAGE_ATTR_SOFTSYN;
	rsb_data.devaddr = RSB_RTSADDR_ACX00X00;
	rsb_data.regaddr = &addr;
	rsb_data.data = &data;

	/* read axp registers */
	ret = arisc_rsb_read_block_data(&rsb_data);
	if (ret != 0) {
		pr_err("failed reads to 0x%02x\n", reg);
		return ret;
	}
	return data;
}
Esempio n. 4
0
static ssize_t arisc_rsb_write_block_data_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{
	ssize_t size = 0;
	u32 ret = 0;

	if ((block_cfg.regaddr == NULL) || (block_cfg.data == NULL) ||
		(block_cfg.devaddr > 0xff) ||
		((block_cfg.datatype !=  RSB_DATA_TYPE_BYTE) && (block_cfg.datatype !=  RSB_DATA_TYPE_HWORD) && (block_cfg.datatype !=  RSB_DATA_TYPE_WORD))) {
		ARISC_WRN("invalid rsb paras, devaddr:0x%x, regaddr:0x%x, datatype:0x%x\n", block_cfg.devaddr, block_cfg.regaddr ? *block_cfg.regaddr : 0, block_cfg.datatype);
		ARISC_WRN("pls echo like that: echo devaddr regaddr data datatype > rsb_write_block_data\n");
		return size;
	}

	ret = arisc_rsb_read_block_data(&block_cfg);
	if (ret) {
		ARISC_ERR("rsb read data:0x%x from devaddr:0x%x regaddr:0x%x fail\n", *block_cfg.data, block_cfg.devaddr, *block_cfg.regaddr);
	} else {
		ARISC_LOG("rsb read data:0x%x from devaddr:0x%x regaddr:0x%x success\n", *block_cfg.data, block_cfg.devaddr, *block_cfg.regaddr);
	}
	size = sprintf(buf, "%x\n", data);

	return size;
}