Doug Thompson | fd3d678 | 2009-04-27 19:50:23 +0200 | [diff] [blame] | 1 | #include "amd64_edac.h" |
| 2 | |
Borislav Petkov | 9cdeb40 | 2010-09-02 18:33:24 +0200 | [diff] [blame] | 3 | #define EDAC_DCT_ATTR_SHOW(reg) \ |
Mauro Carvalho Chehab | c560875 | 2012-03-21 14:00:44 -0300 | [diff] [blame] | 4 | static ssize_t amd64_##reg##_show(struct device *dev, \ |
| 5 | struct device_attribute *mattr, \ |
| 6 | char *data) \ |
Borislav Petkov | 9cdeb40 | 2010-09-02 18:33:24 +0200 | [diff] [blame] | 7 | { \ |
Mauro Carvalho Chehab | c560875 | 2012-03-21 14:00:44 -0300 | [diff] [blame] | 8 | struct mem_ctl_info *mci = to_mci(dev); \ |
Borislav Petkov | 9cdeb40 | 2010-09-02 18:33:24 +0200 | [diff] [blame] | 9 | struct amd64_pvt *pvt = mci->pvt_info; \ |
| 10 | return sprintf(data, "0x%016llx\n", (u64)pvt->reg); \ |
Doug Thompson | fd3d678 | 2009-04-27 19:50:23 +0200 | [diff] [blame] | 11 | } |
| 12 | |
Borislav Petkov | 9cdeb40 | 2010-09-02 18:33:24 +0200 | [diff] [blame] | 13 | EDAC_DCT_ATTR_SHOW(dhar); |
| 14 | EDAC_DCT_ATTR_SHOW(dbam0); |
| 15 | EDAC_DCT_ATTR_SHOW(top_mem); |
| 16 | EDAC_DCT_ATTR_SHOW(top_mem2); |
Doug Thompson | fd3d678 | 2009-04-27 19:50:23 +0200 | [diff] [blame] | 17 | |
Mauro Carvalho Chehab | c560875 | 2012-03-21 14:00:44 -0300 | [diff] [blame] | 18 | static ssize_t amd64_hole_show(struct device *dev, |
| 19 | struct device_attribute *mattr, |
| 20 | char *data) |
Doug Thompson | fd3d678 | 2009-04-27 19:50:23 +0200 | [diff] [blame] | 21 | { |
Mauro Carvalho Chehab | c560875 | 2012-03-21 14:00:44 -0300 | [diff] [blame] | 22 | struct mem_ctl_info *mci = to_mci(dev); |
| 23 | |
Doug Thompson | fd3d678 | 2009-04-27 19:50:23 +0200 | [diff] [blame] | 24 | u64 hole_base = 0; |
| 25 | u64 hole_offset = 0; |
| 26 | u64 hole_size = 0; |
| 27 | |
| 28 | amd64_get_dram_hole_info(mci, &hole_base, &hole_offset, &hole_size); |
| 29 | |
| 30 | return sprintf(data, "%llx %llx %llx\n", hole_base, hole_offset, |
| 31 | hole_size); |
| 32 | } |
| 33 | |
| 34 | /* |
| 35 | * update NUM_DBG_ATTRS in case you add new members |
| 36 | */ |
Mauro Carvalho Chehab | c560875 | 2012-03-21 14:00:44 -0300 | [diff] [blame] | 37 | static DEVICE_ATTR(dhar, S_IRUGO, amd64_dhar_show, NULL); |
| 38 | static DEVICE_ATTR(dbam, S_IRUGO, amd64_dbam0_show, NULL); |
| 39 | static DEVICE_ATTR(topmem, S_IRUGO, amd64_top_mem_show, NULL); |
| 40 | static DEVICE_ATTR(topmem2, S_IRUGO, amd64_top_mem2_show, NULL); |
| 41 | static DEVICE_ATTR(dram_hole, S_IRUGO, amd64_hole_show, NULL); |
Doug Thompson | fd3d678 | 2009-04-27 19:50:23 +0200 | [diff] [blame] | 42 | |
Mauro Carvalho Chehab | c560875 | 2012-03-21 14:00:44 -0300 | [diff] [blame] | 43 | int amd64_create_sysfs_dbg_files(struct mem_ctl_info *mci) |
| 44 | { |
| 45 | int rc; |
| 46 | |
| 47 | rc = device_create_file(&mci->dev, &dev_attr_dhar); |
| 48 | if (rc < 0) |
| 49 | return rc; |
| 50 | rc = device_create_file(&mci->dev, &dev_attr_dbam); |
| 51 | if (rc < 0) |
| 52 | return rc; |
| 53 | rc = device_create_file(&mci->dev, &dev_attr_topmem); |
| 54 | if (rc < 0) |
| 55 | return rc; |
| 56 | rc = device_create_file(&mci->dev, &dev_attr_topmem2); |
| 57 | if (rc < 0) |
| 58 | return rc; |
| 59 | rc = device_create_file(&mci->dev, &dev_attr_dram_hole); |
| 60 | if (rc < 0) |
| 61 | return rc; |
| 62 | |
| 63 | return 0; |
| 64 | } |
| 65 | |
| 66 | void amd64_remove_sysfs_dbg_files(struct mem_ctl_info *mci) |
| 67 | { |
| 68 | device_remove_file(&mci->dev, &dev_attr_dhar); |
| 69 | device_remove_file(&mci->dev, &dev_attr_dbam); |
| 70 | device_remove_file(&mci->dev, &dev_attr_topmem); |
| 71 | device_remove_file(&mci->dev, &dev_attr_topmem2); |
| 72 | device_remove_file(&mci->dev, &dev_attr_dram_hole); |
| 73 | } |