|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* @' Q. o, F9 E) u
#include <linux/init.h>
" u* N: K2 \5 l" s" B#include <linux/module.h>8 j9 X0 p5 ]0 Z( h
#include <linux/kernel.h>
& {- G+ d; [' W0 l#include <linux/types.h>' i a" D, z' C% U0 b. i* O
#include <linux/gpio.h>
- p- h9 P9 W: Q$ X7 q#include <linux/leds.h>
6 J s* d3 }- M# w0 T$ J6 Z#include <linux/platform_device.h>
0 [, S9 Y- T; o1 M& J
6 N7 X; e1 p% @# p4 Q#include <asm/mach-types.h># ~, @: Q8 q& e& P. [: _% j
#include <asm/mach/arch.h>
7 A6 |8 v2 \/ q# y#include <mach/da8xx.h>
9 M- } ~4 z, R6 F4 _#include <mach/mux.h> z5 o# s- B% ^4 i/ p
( R: T W- A& @% c
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). p0 b6 Z& _9 p$ E
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# n! V+ v, I4 [% e6 n0 I6 b4 g) R
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 E9 R! P- ^1 R3 t2 c1 G#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 ?( f T% K9 A
! o; x& u6 w3 a" i4 Q
/* assign the tl som board LED-GPIOs*/
3 n2 `3 G( ]- `' b1 Lstatic const short da850_evm_tl_user_led_pins[] = {, O6 k5 v5 H+ l
/* These pins are definition at <mach/mux.h> file */
7 H, \0 _3 d; |' J% f! W9 I DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- ^' Q. _% b1 ^! ?. F -1
0 X2 H4 V `! ~/ e7 ~+ e" r: a};" U) k/ Z/ y0 W& ]6 Y1 h
4 n+ V& P1 H# ]. T6 T
static struct gpio_led da850_evm_tl_leds[] = {+ `- A3 @$ o( }' S
{- t: e" ~. Z" q+ e8 f: M m9 B
.active_low = 0,
9 j" n" O# }5 E" Z0 X4 q3 w4 q .gpio = DA850_USER_LED0,
% H& a* Y( {% W) p .name = "user_led0",
T+ W4 I$ a/ @7 R .default_trigger = "default-on",7 c: O# W+ v% r6 {) t, V, ~% Z/ v1 {
},% n* V- f+ t9 F& |* W
{# X: C) g5 Y3 p7 z1 m
.active_low = 0,
( z9 \8 `- z/ o& I .gpio = DA850_USER_LED1,# {# J4 {4 l4 ?$ i- |
.name = "user_led1",
& c3 o7 [ u' t/ W7 D9 c. c8 J7 g0 O .default_trigger = "default-on",' J7 `7 `- f# U2 h
},/ o1 L+ Y; N% h0 K
{
: G* w: E: F7 W( V- p .active_low = 0,
, @; W/ F) I+ G3 k( ?) x .gpio = DA850_USER_LED2,: |: ?4 n* S4 t! g- U. Z# l
.name = "user_led2",
1 n2 x% t6 f( n' k .default_trigger = "default-on",! ~: `0 h2 B' Y' }, d' y' O
},0 s" k3 p& g3 c. y3 c
{
% n T! ?2 p, Y3 i .active_low = 0,
" Z- y) q* L+ q0 U9 L; U7 ^ E .gpio = DA850_USER_LED3,
. x* j; A3 ~" x1 z' M8 _, p7 o; ]% R .name = "user_led3",: s/ \( \' w( u+ N5 \9 B( R+ H, V
.default_trigger = "default-on",
+ z) P0 |! s4 o1 f( g },
[$ X+ V) K4 X! K};: n* u2 j% ]3 b( G h6 s
/ x) ^3 ]) `, [6 E
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 V) R' a, N: [0 c0 M3 L" b
.leds = da850_evm_tl_leds,
) p: T5 h/ E) M9 `& I& ^ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: e- i1 Y4 C7 f/ {
};6 v% N3 ~) ?) h( O6 [& |" |9 g# g& j) ]
' W' Q5 D- e/ [' x% ~! t4 B
static void led_dev_release(struct device *dev)
5 X! v2 P' G- j- S{
! Z, U& z r% t};
0 A, k3 i7 m; M0 g
, e Y9 J d% U8 a2 n, Wstatic struct platform_device da850_evm_tl_leds_device = {
$ E. J" [3 ^' f .name = "leds-gpio",
) b! Z. Y7 U5 x7 K; _& V! V7 d .id = 1,
+ \% t' x* [" n .dev = {
) N. I# V. u3 | .platform_data = &da850_evm_tl_leds_pdata,( X+ r8 [7 t& W$ B
.release = led_dev_release,/ }) x0 c' W( S+ H) f+ U% l
}$ y) ]4 {. h. ?$ _) i) C+ D# c# [8 E/ l
};6 ~7 n: J. T6 m1 |
* m) J6 V2 M Z5 m& P4 c" {static int __init led_platform_init(void)+ E! F! S9 ~# t9 U7 X% N5 ~0 A
{
* V5 A) {: J/ H: D9 g8 Q5 n int ret;
, ]& V" g8 X& k- o3 d#if 04 u) X1 B/ _) e) i
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ N9 m; O, A/ ^- D1 a* g5 | if (ret)* @2 W% p" N6 c9 t
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 [ n" [, \1 P- ?! n" \1 A! } "%d\n", ret);# k( e6 x6 z$ { B0 c- k
#endif
8 s$ D B- D/ U3 h- T& i7 u' c' b ret = platform_device_register(&da850_evm_tl_leds_device);9 Q N; Y+ X, r: S8 o( J, o7 s! W- n. Y
if (ret)9 r5 d i# |( K+ P3 L; U
pr_warning("Could not register som GPIO expander LEDS");, m+ M$ t2 E `3 Z$ b+ H
else
' v' D( o6 U; |8 r3 `+ x; e printk(KERN_INFO "LED register sucessful!\n");
2 q4 v! W8 ~ x' U! l5 c7 z5 I0 P* _6 L$ z$ h% H
return ret;
7 O U- k7 ]" ?3 S! s5 S}
7 x. x8 l4 ^" [: O& P
! s* ^ h C; v* [static void __exit led_platform_exit(void)
5 O1 `: R0 F# s& s/ [6 U. r# s) t: N{
/ i+ ~- d; X/ M6 ` platform_device_unregister(&da850_evm_tl_leds_device);) \0 }: [% x2 U+ i
, n" \! q+ J3 `4 d6 A6 `! R printk(KERN_INFO "LED unregister!\n");
" d/ a. U' i( ]* R' v% T9 a3 R# {}# Z; f F) K% h5 X, m, M
: u- C2 b) j9 f. F Imodule_init(led_platform_init);
0 p9 h! n6 W) M, ] U% {% kmodule_exit(led_platform_exit);
4 u( g: m6 E2 K' \0 I0 ~6 h4 }/ t( B7 f6 |2 E) g5 j
MODULE_DESCRIPTION("Led platform driver");% _* _0 z+ n& |3 W. N! X
MODULE_AUTHOR("Tronlong");
- c" b F/ c- J# [# j% j! ~% yMODULE_LICENSE("GPL");1 m7 |8 K: {' A* G8 d( _
8 I3 _5 S% k0 i& T* [
|
|