8
8
#include <linux/errno.h>
9
9
#include <linux/interrupt.h>
10
10
#include <linux/io.h>
11
- #include <linux/mfd/syscon.h>
12
11
#include <linux/miscdevice.h>
13
12
#include <linux/module.h>
14
13
#include <linux/of.h>
15
14
#include <linux/platform_device.h>
16
15
#include <linux/poll.h>
17
- #include <linux/regmap.h>
18
16
#include <linux/sched.h>
19
17
#include <linux/timer.h>
20
18
59
57
struct bt_bmc {
60
58
struct device dev ;
61
59
struct miscdevice miscdev ;
62
- struct regmap * map ;
63
- int offset ;
60
+ void __iomem * base ;
64
61
int irq ;
65
62
wait_queue_head_t queue ;
66
63
struct timer_list poll_timer ;
@@ -69,29 +66,14 @@ struct bt_bmc {
69
66
70
67
static atomic_t open_count = ATOMIC_INIT (0 );
71
68
72
- static const struct regmap_config bt_regmap_cfg = {
73
- .reg_bits = 32 ,
74
- .val_bits = 32 ,
75
- .reg_stride = 4 ,
76
- };
77
-
78
69
static u8 bt_inb (struct bt_bmc * bt_bmc , int reg )
79
70
{
80
- uint32_t val = 0 ;
81
- int rc ;
82
-
83
- rc = regmap_read (bt_bmc -> map , bt_bmc -> offset + reg , & val );
84
- WARN (rc != 0 , "regmap_read() failed: %d\n" , rc );
85
-
86
- return rc == 0 ? (u8 ) val : 0 ;
71
+ return readb (bt_bmc -> base + reg );
87
72
}
88
73
89
74
static void bt_outb (struct bt_bmc * bt_bmc , u8 data , int reg )
90
75
{
91
- int rc ;
92
-
93
- rc = regmap_write (bt_bmc -> map , bt_bmc -> offset + reg , data );
94
- WARN (rc != 0 , "regmap_write() failed: %d\n" , rc );
76
+ writeb (data , bt_bmc -> base + reg );
95
77
}
96
78
97
79
static void clr_rd_ptr (struct bt_bmc * bt_bmc )
@@ -376,18 +358,15 @@ static irqreturn_t bt_bmc_irq(int irq, void *arg)
376
358
{
377
359
struct bt_bmc * bt_bmc = arg ;
378
360
u32 reg ;
379
- int rc ;
380
361
381
- rc = regmap_read (bt_bmc -> map , bt_bmc -> offset + BT_CR2 , & reg );
382
- if (rc )
383
- return IRQ_NONE ;
362
+ reg = readl (bt_bmc -> base + BT_CR2 );
384
363
385
364
reg &= BT_CR2_IRQ_H2B | BT_CR2_IRQ_HBUSY ;
386
365
if (!reg )
387
366
return IRQ_NONE ;
388
367
389
368
/* ack pending IRQs */
390
- regmap_write ( bt_bmc -> map , bt_bmc -> offset + BT_CR2 , reg );
369
+ writel ( reg , bt_bmc -> base + BT_CR2 );
391
370
392
371
wake_up (& bt_bmc -> queue );
393
372
return IRQ_HANDLED ;
@@ -398,6 +377,7 @@ static int bt_bmc_config_irq(struct bt_bmc *bt_bmc,
398
377
{
399
378
struct device * dev = & pdev -> dev ;
400
379
int rc ;
380
+ u32 reg ;
401
381
402
382
bt_bmc -> irq = platform_get_irq_optional (pdev , 0 );
403
383
if (bt_bmc -> irq < 0 )
@@ -417,11 +397,11 @@ static int bt_bmc_config_irq(struct bt_bmc *bt_bmc,
417
397
* will be cleared (along with B2H) when we can write the next
418
398
* message to the BT buffer
419
399
*/
420
- rc = regmap_update_bits (bt_bmc -> map , bt_bmc -> offset + BT_CR1 ,
421
- ( BT_CR1_IRQ_H2B | BT_CR1_IRQ_HBUSY ),
422
- ( BT_CR1_IRQ_H2B | BT_CR1_IRQ_HBUSY ) );
400
+ reg = readl (bt_bmc -> base + BT_CR1 );
401
+ reg |= BT_CR1_IRQ_H2B | BT_CR1_IRQ_HBUSY ;
402
+ writel ( reg , bt_bmc -> base + BT_CR1 );
423
403
424
- return rc ;
404
+ return 0 ;
425
405
}
426
406
427
407
static int bt_bmc_probe (struct platform_device * pdev )
@@ -439,25 +419,9 @@ static int bt_bmc_probe(struct platform_device *pdev)
439
419
440
420
dev_set_drvdata (& pdev -> dev , bt_bmc );
441
421
442
- bt_bmc -> map = syscon_node_to_regmap (pdev -> dev .parent -> of_node );
443
- if (IS_ERR (bt_bmc -> map )) {
444
- void __iomem * base ;
445
-
446
- /*
447
- * Assume it's not the MFD-based devicetree description, in
448
- * which case generate a regmap ourselves
449
- */
450
- base = devm_platform_ioremap_resource (pdev , 0 );
451
- if (IS_ERR (base ))
452
- return PTR_ERR (base );
453
-
454
- bt_bmc -> map = devm_regmap_init_mmio (dev , base , & bt_regmap_cfg );
455
- bt_bmc -> offset = 0 ;
456
- } else {
457
- rc = of_property_read_u32 (dev -> of_node , "reg" , & bt_bmc -> offset );
458
- if (rc )
459
- return rc ;
460
- }
422
+ bt_bmc -> base = devm_platform_ioremap_resource (pdev , 0 );
423
+ if (IS_ERR (bt_bmc -> base ))
424
+ return PTR_ERR (bt_bmc -> base );
461
425
462
426
mutex_init (& bt_bmc -> mutex );
463
427
init_waitqueue_head (& bt_bmc -> queue );
@@ -483,12 +447,12 @@ static int bt_bmc_probe(struct platform_device *pdev)
483
447
add_timer (& bt_bmc -> poll_timer );
484
448
}
485
449
486
- regmap_write (bt_bmc -> map , bt_bmc -> offset + BT_CR0 ,
487
- (BT_IO_BASE << BT_CR0_IO_BASE ) |
450
+ writel ((BT_IO_BASE << BT_CR0_IO_BASE ) |
488
451
(BT_IRQ << BT_CR0_IRQ ) |
489
452
BT_CR0_EN_CLR_SLV_RDP |
490
453
BT_CR0_EN_CLR_SLV_WRP |
491
- BT_CR0_ENABLE_IBT );
454
+ BT_CR0_ENABLE_IBT ,
455
+ bt_bmc -> base + BT_CR0 );
492
456
493
457
clr_b_busy (bt_bmc );
494
458
0 commit comments