9292
9393#define AT91_TWI_FILTR 0x0044
9494#define AT91_TWI_FILTR_FILT BIT(0)
95+ #define AT91_TWI_FILTR_THRES (v ) ((v) << 8)
96+ #define AT91_TWI_FILTR_THRES_MASK GENMASK(10, 8)
9597
9698#define AT91_TWI_FMR 0x0050 /* FIFO Mode Register */
9799#define AT91_TWI_FMR_TXRDYM (mode ) (((mode) & 0x3) << 0)
@@ -118,6 +120,7 @@ struct at91_twi_pdata {
118120 bool has_alt_cmd ;
119121 bool has_hold_field ;
120122 bool has_dig_filtr ;
123+ bool has_adv_dig_filtr ;
121124 struct at_dma_slave dma_slave ;
122125};
123126
@@ -195,6 +198,12 @@ static void at91_init_twi_bus(struct at91_twi_dev *dev)
195198 /* enable digital filter */
196199 if (pdata -> has_dig_filtr && dev -> enable_dig_filt )
197200 at91_twi_write (dev , AT91_TWI_FILTR , AT91_TWI_FILTR_FILT );
201+
202+ /* enable advanced digital filter */
203+ if (pdata -> has_adv_dig_filtr && dev -> enable_dig_filt )
204+ at91_twi_write (dev , AT91_TWI_FILTR , AT91_TWI_FILTR_FILT |
205+ (AT91_TWI_FILTR_THRES (7 ) &
206+ AT91_TWI_FILTR_THRES_MASK ));
198207}
199208
200209/*
@@ -843,6 +852,7 @@ static struct at91_twi_pdata at91rm9200_config = {
843852 .has_alt_cmd = false,
844853 .has_hold_field = false,
845854 .has_dig_filtr = false,
855+ .has_adv_dig_filtr = false,
846856};
847857
848858static struct at91_twi_pdata at91sam9261_config = {
@@ -852,6 +862,7 @@ static struct at91_twi_pdata at91sam9261_config = {
852862 .has_alt_cmd = false,
853863 .has_hold_field = false,
854864 .has_dig_filtr = false,
865+ .has_adv_dig_filtr = false,
855866};
856867
857868static struct at91_twi_pdata at91sam9260_config = {
@@ -861,6 +872,7 @@ static struct at91_twi_pdata at91sam9260_config = {
861872 .has_alt_cmd = false,
862873 .has_hold_field = false,
863874 .has_dig_filtr = false,
875+ .has_adv_dig_filtr = false,
864876};
865877
866878static struct at91_twi_pdata at91sam9g20_config = {
@@ -870,6 +882,7 @@ static struct at91_twi_pdata at91sam9g20_config = {
870882 .has_alt_cmd = false,
871883 .has_hold_field = false,
872884 .has_dig_filtr = false,
885+ .has_adv_dig_filtr = false,
873886};
874887
875888static struct at91_twi_pdata at91sam9g10_config = {
@@ -879,6 +892,7 @@ static struct at91_twi_pdata at91sam9g10_config = {
879892 .has_alt_cmd = false,
880893 .has_hold_field = false,
881894 .has_dig_filtr = false,
895+ .has_adv_dig_filtr = false,
882896};
883897
884898static const struct platform_device_id at91_twi_devtypes [] = {
@@ -910,6 +924,7 @@ static struct at91_twi_pdata at91sam9x5_config = {
910924 .has_alt_cmd = false,
911925 .has_hold_field = false,
912926 .has_dig_filtr = false,
927+ .has_adv_dig_filtr = false,
913928};
914929
915930static struct at91_twi_pdata sama5d4_config = {
@@ -919,6 +934,7 @@ static struct at91_twi_pdata sama5d4_config = {
919934 .has_alt_cmd = false,
920935 .has_hold_field = true,
921936 .has_dig_filtr = true,
937+ .has_adv_dig_filtr = false,
922938};
923939
924940static struct at91_twi_pdata sama5d2_config = {
@@ -928,6 +944,7 @@ static struct at91_twi_pdata sama5d2_config = {
928944 .has_alt_cmd = true,
929945 .has_hold_field = true,
930946 .has_dig_filtr = true,
947+ .has_adv_dig_filtr = true,
931948};
932949
933950static struct at91_twi_pdata sam9x60_config = {
@@ -937,6 +954,7 @@ static struct at91_twi_pdata sam9x60_config = {
937954 .has_alt_cmd = true,
938955 .has_hold_field = true,
939956 .has_dig_filtr = true,
957+ .has_adv_dig_filtr = true,
940958};
941959
942960static const struct of_device_id atmel_twi_dt_ids [] = {
0 commit comments