|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 D( S( d) f& a/ [) r: D- s; L#include <linux/init.h>
, o! p+ E8 O7 r* ^5 P#include <linux/module.h>% d) Y1 ^& J$ j# g
#include <linux/kernel.h>; a" N6 ?1 g, \' B8 k8 f
#include <linux/types.h>' O* K3 w# g' H+ Z9 [
#include <linux/gpio.h>
2 H7 o& A7 b1 X1 k' E3 i. ~9 Y4 J7 a#include <linux/leds.h>
" T' S6 O: u- P, t. J, z% s#include <linux/platform_device.h>% a; X0 z W1 p+ ~
' ]$ K. m4 v/ B7 c8 I) a#include <asm/mach-types.h>; F0 r! O. @8 s. f& O
#include <asm/mach/arch.h>
3 `! t! ]: L/ ]& ^$ c% w#include <mach/da8xx.h>2 G, E$ Y/ [0 y& p% s' E. z
#include <mach/mux.h>
% {/ g- l/ D/ V3 ^% r/ n6 l `' R4 Z M3 r; w- O
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& G9 M( s: O4 \& C3 r' _
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# `3 S' W, H, j( [' p+ Z#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ ]8 t1 o L$ H5 B8 V; O9 ?3 W9 n8 |0 f
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
0 F) \5 I) j1 a
; D7 Y9 ^2 R2 U' R' X/* assign the tl som board LED-GPIOs*/
8 ?8 z- Q0 Z# x7 l$ u% E5 F: ~& Fstatic const short da850_evm_tl_user_led_pins[] = {
+ T; W! P9 w: K6 r2 C5 Q8 R /* These pins are definition at <mach/mux.h> file */& P) A+ t. k8 e
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 n% ~: F3 Z$ R$ k4 a2 n; ^ -1
/ m$ o! \2 e8 R};
* i9 V1 V# @6 U6 h& T5 B9 x: x4 j( D: T9 x) @5 f
static struct gpio_led da850_evm_tl_leds[] = {
- R5 U* @+ s5 e; i) j/ l9 J8 C {. ?# R* E: K; u1 L+ i4 f. s& Y
.active_low = 0,0 y! i" ?. V' e9 `0 J% p
.gpio = DA850_USER_LED0,6 Y! @1 f F+ h. f" B5 ]5 n% ?' T
.name = "user_led0",
; M$ o( m5 g/ Z( g0 S) W1 B .default_trigger = "default-on",+ T' Y/ h4 N; i0 f3 }# B& e1 I" I/ c# [
},
3 S1 S9 O$ N/ V6 M8 J# M! m4 b {
* A) v9 a4 ?& g9 g. k( S .active_low = 0,4 U" f! c, \5 {" P1 W' V @
.gpio = DA850_USER_LED1,7 l3 n! f6 S! _* Q) L% W
.name = "user_led1",* A5 g. _+ b. b: D1 T; O
.default_trigger = "default-on",, n. S" t8 w+ m
},
/ W2 e, l! V" M- H {
9 b; S. p4 M1 F" B .active_low = 0,
& [, E9 A( o! G6 L/ f .gpio = DA850_USER_LED2,* W- B' C4 B) {7 x: O
.name = "user_led2",4 Y7 k* g O" E0 v+ ~9 m
.default_trigger = "default-on",$ R7 l) T' L: r
},0 L- s: H7 w3 J3 R1 x3 `
{
+ I0 d" B8 @ c. p' J .active_low = 0,
! Y, ~0 x) e7 G) z( C) A .gpio = DA850_USER_LED3,& |+ Z0 M- X! |9 r; Z* \
.name = "user_led3",
4 l6 e3 s& U% |* l/ X- ^3 z" i! w .default_trigger = "default-on",
. O0 i! X% T K) ?/ q! `8 d },1 ^) o& _( k/ h6 ]3 ~
};9 u0 S' T0 t5 O3 u) b& p0 o
6 c2 D+ _' W5 Q# J8 i
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' ?4 C( J8 L. _# P) a .leds = da850_evm_tl_leds,
$ |- `9 U) P4 |' v8 E+ o .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* V! T1 D1 T% D' {};. _+ h% _' d% s7 C; [+ s
. y6 m- B) r# W7 n5 I6 t( Cstatic void led_dev_release(struct device *dev); ~; A* e" G9 B4 Y
{( v$ a" S; C: ]
};( J+ V V7 Q7 V# I5 E, D4 e
. N1 ?" ]1 l" C1 i) dstatic struct platform_device da850_evm_tl_leds_device = {
) a2 y7 E4 h/ | .name = "leds-gpio",
; _8 Z* K- `9 W& ?! a7 E; _ .id = 1,. |% a) b6 a. Y1 a$ C7 m5 J
.dev = {& D7 C& L' A* X4 b
.platform_data = &da850_evm_tl_leds_pdata,3 k" b1 L( I4 O# v, T
.release = led_dev_release,9 } c1 P% a6 ?( y1 M
}
! C ?1 H4 S9 u. a};3 @; x) b( W$ y; @" ?2 o" C* w
" u# l* n8 E5 i- b2 F) jstatic int __init led_platform_init(void)
. |2 }1 s5 C+ A& h8 `{
. I1 D* T: ^. s) E; Z6 b int ret;6 x' X1 v+ ~5 t+ q' v0 k; o
#if 0
& c; h9 I8 `8 A5 T3 B& f ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# _# z. I6 L* _- h$ ?1 H if (ret)
9 v) Q! |/ D) {8 a. b" b. T pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; F6 k! O7 u( B& ~/ m "%d\n", ret);
6 K, _. k# Y% ^. V#endif
) y8 s7 S' A: B+ f, o1 {0 @0 ` ret = platform_device_register(&da850_evm_tl_leds_device);
2 [9 N# z3 `+ O D. O1 m& a if (ret)5 L' {& {$ X% f8 S' e4 ?/ q
pr_warning("Could not register som GPIO expander LEDS");0 [& a1 G/ r m) J8 e3 @
else
) l3 X' y7 K5 b0 }6 p: o: d printk(KERN_INFO "LED register sucessful!\n");$ _& Y {2 b' U6 g1 O
* P4 b, S% e |7 R; w8 o2 m/ z
return ret;2 E" [6 m6 b7 j* B+ I2 G! a9 X
}, |6 N" ]7 J- L( i7 A6 A
8 J L' K& B bstatic void __exit led_platform_exit(void); H+ d2 t9 `9 D# i3 L& ]4 _9 p
{2 _- \, Z6 A6 t
platform_device_unregister(&da850_evm_tl_leds_device);* e' Y6 T5 `' @
0 O X1 [& R: q( S printk(KERN_INFO "LED unregister!\n");
* ?* y+ t' M* b8 B$ A}7 E( U) m$ ?7 w" ]
3 ^6 o4 l. S8 @& r' Z$ B9 l hmodule_init(led_platform_init);
/ F) s4 A/ N8 r6 P# D1 Y& \module_exit(led_platform_exit);
|, C: B7 Z( ^* B1 R4 j: y7 A6 }1 j0 ^5 n
MODULE_DESCRIPTION("Led platform driver");
3 ^% w# y+ W9 l6 I" N3 WMODULE_AUTHOR("Tronlong");* T. e& n# p& n' M+ `
MODULE_LICENSE("GPL");4 n7 l3 L# n2 j! m1 x& D7 r
- ^" p3 _- ?) Q
|
|