@@ -57,6 +57,12 @@
mux-gpios = <&gpio ASPEED_GPIO(A, 6) GPIO_ACTIVE_HIGH>;
enable-gpios = <&gpio ASPEED_GPIO(D, 0) GPIO_ACTIVE_HIGH>;
trans-gpios = <&gpio ASPEED_GPIO(R, 2) GPIO_ACTIVE_HIGH>;
+
+ fsi_clock {
+ #clock-cells = <0>;
+ compatible = "fixed-clock";
+ clock-frequency = <8333333>;
+ };
};
};
@@ -18,6 +18,7 @@
#include <linux/idr.h>
#include <linux/kthread.h>
#include <linux/module.h>
+#include <linux/of.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/delay.h>
@@ -26,6 +27,7 @@
#define DEBUG
+#define FSI_DEFAULT_CLK 8333333
#define FSI_N_SLAVES 4
#define FSI_BREAK 0xc0de0000
@@ -139,6 +141,12 @@ int fsi_device_peek(struct fsi_device *dev, void *val)
return fsi_slave_read(dev->slave, addr, val, sizeof(uint32_t));
}
+unsigned long fsi_device_get_clk_rate(struct fsi_device *dev)
+{
+ return dev->slave->master->clk;
+}
+EXPORT_SYMBOL_GPL(fsi_device_get_clk_rate);
+
static void fsi_device_release(struct device *_device)
{
struct fsi_device *device = to_fsi_dev(_device);
@@ -854,9 +862,21 @@ DEVICE_ATTR(fsi_ipoll_period, S_IRUGO | S_IWUSR, fsi_ipoll_period_show,
int fsi_master_register(struct fsi_master *master)
{
+ struct device_node *np;
+ u32 clk;
+
if (!master || !master->dev)
return -EINVAL;
+ master->clk = FSI_DEFAULT_CLK;
+
+ for_each_child_of_node(master->dev->of_node, np) {
+ if (of_device_is_compatible(np, "fixed_clock")) {
+ if (!of_property_read_u32(np, "clock-frequency", &clk))
+ master->clk = clk;
+ }
+ }
+
master->idx = ida_simple_get(&master_ida, 0, INT_MAX, GFP_KERNEL);
master->slave_list = false;
get_device(master->dev);
@@ -72,6 +72,7 @@ struct fsi_master {
int idx;
int n_links;
uint32_t ipoll;
+ unsigned long clk;
int (*read)(struct fsi_master *, int link,
uint8_t slave, uint32_t addr,
void *val, size_t size);
@@ -35,6 +35,7 @@ extern int fsi_device_read(struct fsi_device *dev, uint32_t addr,
extern int fsi_device_write(struct fsi_device *dev, uint32_t addr,
const void *val, size_t size);
extern int fsi_device_peek(struct fsi_device *dev, void *val);
+extern unsigned long fsi_device_get_clk_rate(struct fsi_device *dev);
struct fsi_device_id {
u8 engine_type;